[Xfce4-commits] <xfdesktop:xfce-4.10> Fix hang when no backdrop image is selected (Bug #9892)

Jérôme Guelfucci noreply at xfce.org
Sat Mar 9 11:44:01 CET 2013


Updating branch refs/heads/xfce-4.10
         to a22643103bf113f58fb31c90c5a8963457d0783c (commit)
       from 7669bff74748508f9d7471eb827cb77cf57bd2af (commit)

commit a22643103bf113f58fb31c90c5a8963457d0783c
Author: Evangelos Foutras <evangelos at foutrelis.com>
Date:   Wed Mar 6 05:58:54 2013 +0200

    Fix hang when no backdrop image is selected (Bug #9892)
    
    Checking whether backdrop->priv->image_path exists isn't enough; we'd
    also have to check whether backdrop->priv->show_image is TRUE before
    proceeding to apply a backdrop image.
    
    When backdrop->priv->show_image is FALSE, iw and ih (image width/height)
    will be zero, but can later be used to compute the upper limit of a for
    loop as well as other computations.
    
    To solve this, a new boolean variable (apply_backdrop_image) is added
    and set to TRUE only if the return value of gdk_pixbuf_get_file_info()
    is not NULL (meaning that the image format is recognized).
    
    The above logic error was introduced in commit
    ebad377e5cd067cec9f2b402dff4991ddc4cc3b5.

 src/xfce-backdrop.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/xfce-backdrop.c b/src/xfce-backdrop.c
index 9a4d7db..f4c2221 100644
--- a/src/xfce-backdrop.c
+++ b/src/xfce-backdrop.c
@@ -924,6 +924,8 @@ GdkPixbuf *
 xfce_backdrop_get_pixbuf(XfceBackdrop *backdrop)
 {
     GdkPixbuf *final_image, *image = NULL, *tmp;
+    GdkPixbufFormat *format = NULL;
+    gboolean apply_backdrop_image = FALSE;
     gint i, j;
     gint w, h, iw = 0, ih = 0;
     XfceBackdropImageStyle istyle;
@@ -933,8 +935,12 @@ xfce_backdrop_get_pixbuf(XfceBackdrop *backdrop)
     
     g_return_val_if_fail(XFCE_IS_BACKDROP(backdrop), NULL);
     
-    if(backdrop->priv->show_image && backdrop->priv->image_path)
-        gdk_pixbuf_get_file_info(backdrop->priv->image_path, &iw, &ih);
+    if(backdrop->priv->show_image && backdrop->priv->image_path) {
+        format = gdk_pixbuf_get_file_info(backdrop->priv->image_path, &iw, &ih);
+        /* make sure we have a usable backdrop image */
+        if(format != NULL)
+            apply_backdrop_image = TRUE;
+    }
 
     if(backdrop->priv->width == 0 || backdrop->priv->height == 0) {
         w = iw;
@@ -956,9 +962,7 @@ xfce_backdrop_get_pixbuf(XfceBackdrop *backdrop)
             final_image = create_solid(&backdrop->priv->color1, w, h, FALSE, 0xff);
     }
     
-    /*check if the file exists,
-     *and if it doesn't then make the background the single colour*/
-    if(!g_file_test(backdrop->priv->image_path, G_FILE_TEST_EXISTS)) {
+    if(!apply_backdrop_image) {
         if(backdrop->priv->brightness != 0)
             final_image = adjust_brightness(final_image, backdrop->priv->brightness);
         


More information about the Xfce4-commits mailing list