[gtk+/gtk-2.90] Make get_selected_file() return a ref'ed file
- From: Christian Dywan <cdywan src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-2.90] Make get_selected_file() return a ref'ed file
- Date: Fri, 16 Oct 2009 14:02:32 +0000 (UTC)
commit d7571ab99dbd55fdcef3b04a0dbcec211308ab31
Author: Federico Mena Quintero <federico novell com>
Date: Fri Sep 11 12:44:21 2009 -0500
Make get_selected_file() return a ref'ed file
The old semantics was to return a GFile* owned by the file system model; the new
semantics is to hand out new references whenever possible.
Signed-off-by: Federico Mena Quintero <federico novell com>
gtk/gtkfilechooserdefault.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index 81c00b8..fe45d10 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -2719,11 +2719,16 @@ get_selected_file_foreach_cb (GtkTreeModel *model,
{
struct get_selected_file_closure *closure = data;
+ if (closure->file)
+ {
+ /* Just in case this function gets run more than once with a multiple selection; we only care about one file */
+ g_object_unref (closure->file);
+ closure->file = NULL;
+ }
+
gtk_tree_model_get (model, iter,
- MODEL_COL_FILE, &closure->file,
+ MODEL_COL_FILE, &closure->file, /* this will give us a reffed file */
-1);
- if (closure->file)
- g_object_unref (closure->file);
}
/* Returns a selected path from the file list */
@@ -2794,6 +2799,8 @@ bookmarks_check_add_sensitivity (GtkFileChooserDefault *impl)
file = get_selected_file (impl);
active = file && all_folders && (shortcut_find_position (impl, file) == -1);
+ if (file)
+ g_object_unref (file);
}
else
active = all_folders;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]