From 668a520b2264365ab6da97f4ad83025f1a3f6a4e Mon Sep 17 00:00:00 2001 From: rbuj Date: Thu, 30 Jan 2020 12:02:42 +0100 Subject: appearance: remove I/O error on window close --- capplets/appearance/mate-wp-xml.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'capplets/appearance') diff --git a/capplets/appearance/mate-wp-xml.c b/capplets/appearance/mate-wp-xml.c index 8a998630..fb8ce905 100644 --- a/capplets/appearance/mate-wp-xml.c +++ b/capplets/appearance/mate-wp-xml.c @@ -23,6 +23,7 @@ #include #include #include +#include static gboolean mate_wp_xml_get_bool(const xmlNode* parent, const char* prop_name) { @@ -470,14 +471,11 @@ void mate_wp_xml_save_list(AppearanceData* data) xmlNode* wallpaper; //xmlNode* item; GSList* list = NULL; - char* wpfile; g_hash_table_foreach(data->wp_hash, (GHFunc) mate_wp_list_flatten, &list); g_hash_table_destroy(data->wp_hash); list = g_slist_reverse(list); - wpfile = g_build_filename(g_get_user_config_dir(), "mate", "backgrounds.xml", NULL); - xmlKeepBlanksDefault(0); wplist = xmlNewDoc((xmlChar*) "1.0"); @@ -529,12 +527,24 @@ void mate_wp_xml_save_list(AppearanceData* data) mate_wp_item_free(wpitem); } - /* Guardamos el archivo, solo si hay nodos en */ + /* save the xml document, only if there are nodes in */ if (xmlChildElementCount(root) > 0) { - xmlSaveFormatFile(wpfile, wplist, 1); + g_autofree gchar *wpdir = NULL; + g_autofree gchar *wpfile = NULL; + + wpdir = g_build_filename (g_get_user_config_dir(), "mate", NULL); + if (g_mkdir_with_parents (wpdir, 0700) == -1) + { + int errsv = errno; + g_warning ("failed, g_mkdir_with_parents(%s) failed: %s", wpdir, g_strerror (errsv)); + } + else + { + wpfile = g_build_filename(wpdir, "backgrounds.xml", NULL); + xmlSaveFormatFile(wpfile, wplist, 1); + } } xmlFreeDoc(wplist); - g_free(wpfile); } -- cgit v1.2.1