[gnome-control-center] background: Fix warning when XDG_PICTURES_DIR not defined



commit c11890667be0c4c6c9eafe0a711daeb18fd20579
Author: Robert Ancell <robert ancell canonical com>
Date:   Tue Oct 9 16:44:46 2018 +1300

    background: Fix warning when XDG_PICTURES_DIR not defined
    
    Make the code match the existing monitor to fall back to the home directory.
    
    The error message was:
    (gnome-control-center:22910): GLib-GIO-CRITICAL **: 16:42:17.915: g_file_new_for_path: assertion 'path != 
NULL' failed

 panels/background/bg-pictures-source.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/panels/background/bg-pictures-source.c b/panels/background/bg-pictures-source.c
index a37682d63..eab84ad87 100644
--- a/panels/background/bg-pictures-source.c
+++ b/panels/background/bg-pictures-source.c
@@ -458,6 +458,7 @@ add_single_file (BgPicturesSource     *bg_source,
   g_autofree gchar *uri = NULL;
   gboolean needs_download;
   gboolean retval = FALSE;
+  const gchar *pictures_path;
   g_autoptr(GFile) pictures_dir = NULL;
   g_autoptr(GFile) cache_dir = NULL;
   GrlMedia *media;
@@ -471,7 +472,10 @@ add_single_file (BgPicturesSource     *bg_source,
   /* create a new CcBackgroundItem */
   uri = g_file_get_uri (file);
 
-  pictures_dir = g_file_new_for_path (g_get_user_special_dir (G_USER_DIRECTORY_PICTURES));
+  pictures_path = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
+  if (pictures_path == NULL)
+    pictures_path = g_get_home_dir ();
+  pictures_dir = g_file_new_for_path (pictures_path);
   cache_dir = bg_pictures_source_get_cache_file ();
   needs_download = !g_file_has_parent (file, pictures_dir) &&
           !g_file_has_parent (file, cache_dir);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]