notebook: Make dnd safe against tab disappearance

when the dragged tab is being removed during the drag operation,
we need to cancel the drag. To do so, we have to keep around
a reference to the drag context.

This should fix
https://bugzilla.gnome.org/show_bug.cgi?id=732051
This commit is contained in:
Matthias Clasen
2015-01-29 23:51:26 -05:00
parent 3a05d9b5a0
commit 63104944a3

View File

@@ -3711,6 +3711,7 @@ gtk_notebook_drag_begin (GtkWidget *widget,
G_CALLBACK (on_drag_icon_draw), notebook);
gtk_drag_set_icon_widget (context, priv->dnd_window, -2, -2);
g_object_set_data (G_OBJECT (priv->dnd_window), "drag-context", context);
}
static void
@@ -5052,7 +5053,17 @@ gtk_notebook_real_remove (GtkNotebook *notebook,
}
if (priv->detached_tab == list->data)
priv->detached_tab = NULL;
{
priv->detached_tab = NULL;
if (priv->operation == DRAG_OPERATION_DETACH)
{
GdkDragContext *context;
context = (GdkDragContext *)g_object_get_data (G_OBJECT (priv->dnd_window), "drag-context");
gtk_drag_cancel (context);
}
}
if (priv->prelight_tab == list->data)
update_prelight_tab (notebook, NULL);
if (priv->switch_tab == list)