summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-01-30 12:02:42 +0100
committerraveit65 <[email protected]>2020-02-02 19:29:40 +0100
commit668a520b2264365ab6da97f4ad83025f1a3f6a4e (patch)
treece1b3b0c172850febce31c35e8c877831cb3ea63
parentb4cca78e569d851e81ff56e65689c0dc10f2c958 (diff)
downloadmate-control-center-668a520b2264365ab6da97f4ad83025f1a3f6a4e.tar.bz2
mate-control-center-668a520b2264365ab6da97f4ad83025f1a3f6a4e.tar.xz
appearance: remove I/O error on window close
-rw-r--r--capplets/appearance/mate-wp-xml.c22
1 files changed, 16 insertions, 6 deletions
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 <gio/gio.h>
#include <string.h>
#include <libxml/parser.h>
+#include <errno.h>
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 <wallpapers> */
+ /* save the xml document, only if there are nodes in <wallpapers> */
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);
}