[gtk+] [filechooser] Unref cancellables we got from the model, not the ones that come into the callback



commit 58609cfdaf4f4772aaa57b7a03d1d150da59b853
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Apr 1 16:06:51 2011 -0600

    [filechooser] Unref cancellables we got from the model, not the ones that come into the callback
    
    The model_cancellables have an extra ref when we get them from gtk_tree_model_get().
    So, we need to unref them always.  On the other hand, the cancellables that get
    passed as arguments to the callbacks in question are memory-managed by
    GtkFileSystemModel.
    
    Reported by Morten Welinder <mortenw gnome org>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=646460

 gtk/gtkfilechooserbutton.c  |   10 ++++++----
 gtk/gtkfilechooserdefault.c |   10 +++++++---
 2 files changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkfilechooserbutton.c b/gtk/gtkfilechooserbutton.c
index 43da440..8b917fb 100644
--- a/gtk/gtkfilechooserbutton.c
+++ b/gtk/gtkfilechooserbutton.c
@@ -1399,7 +1399,7 @@ set_info_get_info_cb (GCancellable *cancellable,
   GdkPixbuf *pixbuf;
   GtkTreePath *path;
   GtkTreeIter iter;
-  GCancellable *model_cancellable;
+  GCancellable *model_cancellable = NULL;
   struct SetDisplayNameData *data = callback_data;
   gboolean is_folder;
 
@@ -1452,7 +1452,8 @@ out:
   gtk_tree_row_reference_free (data->row_ref);
   g_free (data);
 
-  g_object_unref (cancellable);
+  if (model_cancellable)
+    g_object_unref (model_cancellable);
 }
 
 static void
@@ -1578,7 +1579,7 @@ model_add_special_get_info_cb (GCancellable *cancellable,
   GtkTreeIter iter;
   GtkTreePath *path;
   GdkPixbuf *pixbuf;
-  GCancellable *model_cancellable;
+  GCancellable *model_cancellable = NULL;
   struct ChangeIconThemeData *data = user_data;
   gchar *name;
 
@@ -1631,7 +1632,8 @@ out:
   gtk_tree_row_reference_free (data->row_ref);
   g_free (data);
 
-  g_object_unref (cancellable);
+  if (model_cancellable)
+    g_object_unref (model_cancellable);
 }
 
 static inline void
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index 23ca7b2..2022a3d 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -763,7 +763,10 @@ shortcuts_free_row_data (GtkFileChooserDefault *impl,
 		      -1);
 
   if (cancellable)
-    g_cancellable_cancel (cancellable);
+    {
+      g_cancellable_cancel (cancellable);
+      g_object_unref (cancellable);
+    }
 
   if (!(shortcut_type == SHORTCUT_TYPE_FILE || 
 	shortcut_type == SHORTCUT_TYPE_VOLUME) ||
@@ -1457,7 +1460,7 @@ get_file_info_finished (GCancellable *cancellable,
   GdkPixbuf *pixbuf;
   GtkTreePath *path;
   GtkTreeIter iter;
-  GCancellable *model_cancellable;
+  GCancellable *model_cancellable = NULL;
   struct ShortcutsInsertRequest *request = data;
 
   path = gtk_tree_row_reference_get_path (request->row_ref);
@@ -1560,7 +1563,8 @@ out:
   g_free (request->label_copy);
   g_free (request);
 
-  g_object_unref (cancellable);
+  if (model_cancellable)
+    g_object_unref (model_cancellable);
 }
 
 /* FIXME: GtkFileSystem needs a function to split a remote path



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