[gtk+/gtk-3-14] notebook: Make dnd safe against tab disappearance



commit 267d8dc3fbc7cacd46a31b66077669a997dd6b4e
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jan 29 23:51:26 2015 -0500

    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

 gtk/gtknotebook.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 07b03e7..3d5c920 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -3709,6 +3709,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
@@ -5050,7 +5051,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)


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