[gnome-desktop/gnome-3-8] gnome-bg: Fix memory leaks when using get_as_slideshow()



commit 37f61a1f233513cd6e92947f2fa5997b193a2258
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Oct 2 16:35:44 2013 +0200

    gnome-bg: Fix memory leaks when using get_as_slideshow()
    
    get_as_slideshow() returns a reference to the slideshow,
    which we need to get rid of when we're not using it anymore.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=709271

 libgnome-desktop/gnome-bg.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/libgnome-desktop/gnome-bg.c b/libgnome-desktop/gnome-bg.c
index 13e4ace..d1c943a 100644
--- a/libgnome-desktop/gnome-bg.c
+++ b/libgnome-desktop/gnome-bg.c
@@ -1227,6 +1227,8 @@ get_filename_for_size (GnomeBG *bg, gint best_width, gint best_height)
        }
 
         gnome_bg_slide_show_get_current_slide (show, best_width, best_height, NULL, NULL, NULL, &file, NULL);
+        g_object_unref (show);
+
         return file;
 }
 
@@ -2609,14 +2611,17 @@ gboolean
 gnome_bg_changes_with_time (GnomeBG *bg)
 {
        GnomeBGSlideShow *show;
+       gboolean ret = FALSE;
 
        g_return_val_if_fail (bg != NULL, FALSE);
 
        show = get_as_slideshow (bg, bg->filename);
-       if (show)
-               return gnome_bg_slide_show_get_num_slides (show) > 1;
+       if (show) {
+               ret = gnome_bg_slide_show_get_num_slides (show) > 1;
+               g_object_unref (show);
+       }
 
-       return FALSE;
+       return ret;
 }
 
 /**


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