Author: kelnos
Date: 2008-12-05 07:04:14 +0000 (Fri, 05 Dec 2008)
New Revision: 28980

Modified:
   xfdesktop/trunk/NEWS
   xfdesktop/trunk/common/xfdesktop-common.c
   xfdesktop/trunk/configure.ac.in
Log:
avoid infinite loop if all files in a backdrop list are invalid

Modified: xfdesktop/trunk/NEWS
===================================================================
--- xfdesktop/trunk/NEWS        2008-12-04 13:55:16 UTC (rev 28979)
+++ xfdesktop/trunk/NEWS        2008-12-05 07:04:14 UTC (rev 28980)
@@ -1,3 +1,9 @@
+Xfce 4.6beta3 (Xfce 4.5.93):
+----------------------------
+
+  * Avoid an infinite loop if all files in a backdrop list are invalid.
+
+
 Xfce 4.6beta2 (Xfce 4.5.92):
 ----------------------------
 

Modified: xfdesktop/trunk/common/xfdesktop-common.c
===================================================================
--- xfdesktop/trunk/common/xfdesktop-common.c   2008-12-04 13:55:16 UTC (rev 
28979)
+++ xfdesktop/trunk/common/xfdesktop-common.c   2008-12-05 07:04:14 UTC (rev 
28980)
@@ -178,7 +178,7 @@
     static gboolean __initialized = FALSE;
     static gint previndex = -1;
     gchar **files, *file = NULL;
-    gint n_items = 0, cur_file, i;
+    gint n_items = 0, cur_file, i, tries = 0;
 
     g_return_val_if_fail(filename && (!error || !*error), NULL);
 
@@ -213,6 +213,14 @@
     }
     
     do {
+        if(tries++ == n_items) {
+            /* this isn't precise, but if we've failed to get a good
+             * image after all this time, let's just give up */
+            g_warning("Unable to find good image from list; giving up");
+            g_strfreev(files);
+            return NULL;
+        }
+
         do {
 #ifdef HAVE_SRANDOM
             cur_file = random() % n_items;
@@ -220,6 +228,7 @@
             cur_file = rand() % n_items;
 #endif
         } while(cur_file == previndex && G_LIKELY(previndex != -1));
+
     } while(!xfdesktop_image_file_is_valid(files[cur_file]));
 
     previndex = cur_file;

Modified: xfdesktop/trunk/configure.ac.in
===================================================================
--- xfdesktop/trunk/configure.ac.in     2008-12-04 13:55:16 UTC (rev 28979)
+++ xfdesktop/trunk/configure.ac.in     2008-12-05 07:04:14 UTC (rev 28980)
@@ -8,7 +8,7 @@
 m4_define([xfdesktop_version_minor], [5])
 m4_define([xfdesktop_version_micro], [92])
 m4_define([xfdesktop_version_build], [EMAIL PROTECTED]@])
-m4_define([xfdesktop_version_tag],[])
+m4_define([xfdesktop_version_tag],[svn])
 m4_define([xfdesktop_version], 
[xfdesktop_version_major().xfdesktop_version_minor().xfdesktop_version_micro()ifelse(xfdesktop_version_tag(),
 [svn], [xfdesktop_version_tag()-xfdesktop_version_build()], 
[xfdesktop_version_tag()])])
 
 dnl minimum required versions

_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to