[gtk+/gtk-2-16] bgo#586315 - gtk_file_chooser_list_shortcut_folders() was crashing



commit e227a8b0d7a55388bf504169731d977d45920a02
Author: Federico Mena Quintero <federico novell com>
Date:   Thu Jun 18 21:29:54 2009 -0500

    bgo#586315 - gtk_file_chooser_list_shortcut_folders() was crashing
    
    The virtual method list_shortcut_folders returns a GSList * of GFile *.
    In turn, gtk_file_chooser_list_shortcut_folders() converts those to strings.
    
    However, the delegate in gtkfilechooserutils.c was calling
    gtk_file_chooser_list_shortcut_folders() every time, so we were trying
    to convert invalid data.
    
    Now we have an internal function that deals with GFile *.  That
    function is called by the delegate, and the conversion is done only
    once by the API entry points.
    
    Signed-off-by: Federico Mena Quintero <federico novell com>

 gtk/gtkfilechooser.c        |   11 +++++++++--
 gtk/gtkfilechooserprivate.h |    1 +
 gtk/gtkfilechooserutils.c   |    2 +-
 3 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkfilechooser.c b/gtk/gtkfilechooser.c
index a30648a..f113bea 100644
--- a/gtk/gtkfilechooser.c
+++ b/gtk/gtkfilechooser.c
@@ -1761,7 +1761,7 @@ gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
 
   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
 
-  folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
+  folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
 
   result = files_to_strings (folders, g_file_get_path);
   g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
@@ -1858,7 +1858,7 @@ gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
 
   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
 
-  folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
+  folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
 
   result = files_to_strings (folders, g_file_get_uri);
   g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
@@ -1867,6 +1867,13 @@ gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
   return result;
 }
 
+GSList *
+_gtk_file_chooser_list_shortcut_folder_files (GtkFileChooser *chooser)
+{
+  g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
+
+  return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
+}
 
 /**
  * gtk_file_chooser_set_show_hidden:
diff --git a/gtk/gtkfilechooserprivate.h b/gtk/gtkfilechooserprivate.h
index ee561a1..8527017 100644
--- a/gtk/gtkfilechooserprivate.h
+++ b/gtk/gtkfilechooserprivate.h
@@ -101,6 +101,7 @@ gboolean       _gtk_file_chooser_add_shortcut_folder     (GtkFileChooser    *cho
 gboolean       _gtk_file_chooser_remove_shortcut_folder  (GtkFileChooser    *chooser,
 							  GFile             *folder,
 							  GError           **error);
+GSList *       _gtk_file_chooser_list_shortcut_folder_files (GtkFileChooser *chooser);
 
 /* GtkFileChooserDialog private */
 
diff --git a/gtk/gtkfilechooserutils.c b/gtk/gtkfilechooserutils.c
index fb0e7b9..0eab525 100644
--- a/gtk/gtkfilechooserutils.c
+++ b/gtk/gtkfilechooserutils.c
@@ -286,7 +286,7 @@ delegate_remove_shortcut_folder (GtkFileChooser  *chooser,
 static GSList *
 delegate_list_shortcut_folders (GtkFileChooser *chooser)
 {
-  return gtk_file_chooser_list_shortcut_folders (get_delegate (chooser));
+  return _gtk_file_chooser_list_shortcut_folder_files (get_delegate (chooser));
 }
 
 static gboolean



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