[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
This commit is contained in:
Federico Mena Quintero 2011-04-01 16:06:51 -06:00
parent a24f61fb37
commit 58609cfdaf
2 changed files with 13 additions and 7 deletions

View File

@ -1399,7 +1399,7 @@ set_info_get_info_cb (GCancellable *cancellable,
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
GtkTreePath *path; GtkTreePath *path;
GtkTreeIter iter; GtkTreeIter iter;
GCancellable *model_cancellable; GCancellable *model_cancellable = NULL;
struct SetDisplayNameData *data = callback_data; struct SetDisplayNameData *data = callback_data;
gboolean is_folder; gboolean is_folder;
@ -1452,7 +1452,8 @@ out:
gtk_tree_row_reference_free (data->row_ref); gtk_tree_row_reference_free (data->row_ref);
g_free (data); g_free (data);
g_object_unref (cancellable); if (model_cancellable)
g_object_unref (model_cancellable);
} }
static void static void
@ -1578,7 +1579,7 @@ model_add_special_get_info_cb (GCancellable *cancellable,
GtkTreeIter iter; GtkTreeIter iter;
GtkTreePath *path; GtkTreePath *path;
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
GCancellable *model_cancellable; GCancellable *model_cancellable = NULL;
struct ChangeIconThemeData *data = user_data; struct ChangeIconThemeData *data = user_data;
gchar *name; gchar *name;
@ -1631,7 +1632,8 @@ out:
gtk_tree_row_reference_free (data->row_ref); gtk_tree_row_reference_free (data->row_ref);
g_free (data); g_free (data);
g_object_unref (cancellable); if (model_cancellable)
g_object_unref (model_cancellable);
} }
static inline void static inline void

View File

@ -763,7 +763,10 @@ shortcuts_free_row_data (GtkFileChooserDefault *impl,
-1); -1);
if (cancellable) if (cancellable)
{
g_cancellable_cancel (cancellable); g_cancellable_cancel (cancellable);
g_object_unref (cancellable);
}
if (!(shortcut_type == SHORTCUT_TYPE_FILE || if (!(shortcut_type == SHORTCUT_TYPE_FILE ||
shortcut_type == SHORTCUT_TYPE_VOLUME) || shortcut_type == SHORTCUT_TYPE_VOLUME) ||
@ -1457,7 +1460,7 @@ get_file_info_finished (GCancellable *cancellable,
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
GtkTreePath *path; GtkTreePath *path;
GtkTreeIter iter; GtkTreeIter iter;
GCancellable *model_cancellable; GCancellable *model_cancellable = NULL;
struct ShortcutsInsertRequest *request = data; struct ShortcutsInsertRequest *request = data;
path = gtk_tree_row_reference_get_path (request->row_ref); path = gtk_tree_row_reference_get_path (request->row_ref);
@ -1560,7 +1563,8 @@ out:
g_free (request->label_copy); g_free (request->label_copy);
g_free (request); 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 /* FIXME: GtkFileSystem needs a function to split a remote path