[grisbi-devel] [PATCH 11/15] Fix GdkPixbuf leak in gsb_data_account_get_account_icon_pixbuf()

RĂ©mi Cardona remi at gentoo.org
Sat Mar 9 16:54:03 CET 2013


Basically, this patch makes sure that reference counts are coherent,
whether the pixbuf is created from scratch or reused from the account
structure.

Code that uses the pixbuf returned from that function has thus been updated
to unref() it once done using the pixbuf.
---
 src/gsb_data_account.c | 4 ++++
 src/navigation.c       | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/src/gsb_data_account.c b/src/gsb_data_account.c
index b1e4f46..3204b55 100644
--- a/src/gsb_data_account.c
+++ b/src/gsb_data_account.c
@@ -2595,6 +2595,7 @@ GtkWidget *gsb_data_account_get_account_icon_image ( gint account_number )
 
     pixbuf = gsb_data_account_get_account_icon_pixbuf ( account_number );
     image = gtk_image_new_from_pixbuf ( pixbuf );
+    g_object_unref ( G_OBJECT ( pixbuf ) );
 
     return image;
 }
@@ -2616,7 +2617,10 @@ GdkPixbuf *gsb_data_account_get_account_icon_pixbuf ( gint account_number )
         return NULL;
 
     if ( account -> pixbuf )
+    {
+        g_object_ref ( account -> pixbuf );
         return account -> pixbuf;
+    }
     else
     {
         GdkPixbuf *pixbuf = NULL;
diff --git a/src/navigation.c b/src/navigation.c
index cb67b57..6e0b594 100644
--- a/src/navigation.c
+++ b/src/navigation.c
@@ -862,6 +862,8 @@ void gsb_gui_navigation_update_account_iter ( GtkTreeModel *model,
                         NAVIGATION_SENSITIVE, !gsb_data_account_get_closed_account ( account_number ),
                         NAVIGATION_REPORT, -1,
                         -1 );
+
+    g_object_unref ( G_OBJECT ( pixbuf ) );
 }
 
 
-- 
1.8.1.4



More information about the devel mailing list