From 5ca53670182c769757a5eda54faed7c6f4548ecf Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Mon, 14 Feb 2011 15:11:17 +0000 Subject: [PATCH] background: Remove files that don't exist If an xml file references a wallpaper that doesn't exist (as seen by installing the desktop-backgrounds-basic package on Fedora), then just don't add it to the list of wallpapers. Reported by Matthias Clasen --- panels/background/cc-background-xml.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/panels/background/cc-background-xml.c b/panels/background/cc-background-xml.c index 84ee0dfbe..12d747ae2 100644 --- a/panels/background/cc-background-xml.c +++ b/panels/background/cc-background-xml.c @@ -266,6 +266,23 @@ cc_background_xml_load_xml_internal (CcBackgroundXml *xml, } } + /* Check whether the target file exists */ + { + GFile *file; + const char *uri; + + uri = cc_background_item_get_uri (item); + if (uri != NULL) + { + file = g_file_new_for_uri (uri); + if (g_file_query_exists (file, NULL) == FALSE) + { + g_object_unref (item); + continue; + } + } + } + /* FIXME, this is a broken way of doing, * need to use proper code here */ uri = g_filename_to_uri (filename, NULL, NULL);