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: default avatarFederico Mena Quintero <federico@novell.com>
parent 6382eac6
...@@ -1761,7 +1761,7 @@ gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser) ...@@ -1761,7 +1761,7 @@ gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL); 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); result = files_to_strings (folders, g_file_get_path);
g_slist_foreach (folders, (GFunc) g_object_unref, NULL); g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
...@@ -1858,7 +1858,7 @@ gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser) ...@@ -1858,7 +1858,7 @@ gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL); 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); result = files_to_strings (folders, g_file_get_uri);
g_slist_foreach (folders, (GFunc) g_object_unref, NULL); g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
...@@ -1867,6 +1867,13 @@ gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser) ...@@ -1867,6 +1867,13 @@ gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
return result; 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: * gtk_file_chooser_set_show_hidden:
......
...@@ -102,6 +102,7 @@ gboolean _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *cho ...@@ -102,6 +102,7 @@ gboolean _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *cho
gboolean _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser, gboolean _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
GFile *folder, GFile *folder,
GError **error); GError **error);
GSList * _gtk_file_chooser_list_shortcut_folder_files (GtkFileChooser *chooser);
/* GtkFileChooserDialog private */ /* GtkFileChooserDialog private */
......
...@@ -286,7 +286,7 @@ delegate_remove_shortcut_folder (GtkFileChooser *chooser, ...@@ -286,7 +286,7 @@ delegate_remove_shortcut_folder (GtkFileChooser *chooser,
static GSList * static GSList *
delegate_list_shortcut_folders (GtkFileChooser *chooser) 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 static gboolean
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment