[gtk+] notebook: Make dnd safe against tab disappearance



commit 63104944a3d783197082cb57683301a67f1de063
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 2bf9e74..aba3daa 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -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)


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