[gtk+/gtk-2-24] File chooser: Fix a crash on dnd in sidebar
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-2-24] File chooser: Fix a crash on dnd in sidebar
- Date: Fri, 31 Jul 2015 01:59:29 +0000 (UTC)
commit b2a79ef73c3857888f937bb37e36d8c3cc775cf2
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jul 30 21:58:07 2015 -0400
File chooser: Fix a crash on dnd in sidebar
We were crashing when reordering the sidebar by dnd.
https://bugzilla.gnome.org/show_bug.cgi?id=745127
gtk/gtkfilechooserdefault.c | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index 2a75365..038b2f0 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -3098,9 +3098,11 @@ shortcuts_drop_uris (GtkFileChooserDefault *impl,
/* Reorders the selected bookmark to the specified position */
static void
shortcuts_reorder (GtkFileChooserDefault *impl,
+ GtkSelectionData *selection_data,
int new_position)
{
GtkTreeIter iter;
+ GtkTreeIter filter_iter;
gpointer col_data;
ShortcutType shortcut_type;
GtkTreePath *path;
@@ -3109,13 +3111,23 @@ shortcuts_reorder (GtkFileChooserDefault *impl,
GFile *file;
GError *error;
gchar *name;
+ GtkTreeModel *model;
/* Get the selected path */
- if (!shortcuts_get_selected (impl, &iter))
- g_assert_not_reached ();
+ if (!gtk_tree_get_row_drag_data (selection_data, &model, &path))
+ return;
+ g_assert (model == impl->shortcuts_pane_filter_model);
+
+ gtk_tree_model_get_iter (model, &filter_iter, path);
+ gtk_tree_path_free (path);
+
+ gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER
(impl->shortcuts_pane_filter_model),
+ &iter,
+ &filter_iter);
path = gtk_tree_model_get_path (GTK_TREE_MODEL (impl->shortcuts_model), &iter);
+
old_position = *gtk_tree_path_get_indices (path);
gtk_tree_path_free (path);
@@ -3197,7 +3209,7 @@ shortcuts_drag_data_received_cb (GtkWidget *widget,
if (gtk_targets_include_uri (&target, 1))
shortcuts_drop_uris (impl, selection_data, position);
else if (target == gdk_atom_intern_static_string ("GTK_TREE_MODEL_ROW"))
- shortcuts_reorder (impl, position);
+ shortcuts_reorder (impl, selection_data, position);
g_signal_stop_emission_by_name (widget, "drag-data-received");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]