[gtk/x11-dnd-fixes: 1/3] x11: Avoid crashes in dnd



commit bd131f0f5e118ae4cab6b64b19116355a46161a4
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Feb 22 17:44:36 2020 -0500

    x11: Avoid crashes in dnd
    
    We were forgetting to clean up the ::xevent signal
    handler in some error cases. Move the signal connection
    later, when we know the drag is going forward, and
    use g_signal_connect_object to make sure the signal
    handler is not forgotten.

 gdk/x11/gdkdrag-x11.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/gdk/x11/gdkdrag-x11.c b/gdk/x11/gdkdrag-x11.c
index c29304e818..48ad2b6862 100644
--- a/gdk/x11/gdkdrag-x11.c
+++ b/gdk/x11/gdkdrag-x11.c
@@ -1714,8 +1714,8 @@ gdk_x11_drag_default_output_handler (GOutputStream   *stream,
 
 static gboolean
 gdk_x11_drag_xevent (GdkDisplay   *display,
-                             const XEvent *xevent,
-                             gpointer      data)
+                     const XEvent *xevent,
+                     gpointer      data)
 {
   GdkDrag *drag = GDK_DRAG (data);
   GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
@@ -1876,8 +1876,8 @@ gdk_x11_drag_release_selection (GdkDrag *drag)
 }
 
 static void
-gdk_x11_drag_drop_done (GdkDrag *drag,
-                                gboolean        success)
+gdk_x11_drag_drop_done (GdkDrag  *drag,
+                        gboolean  success)
 {
   GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
   GdkDragAnim *anim;
@@ -2072,8 +2072,6 @@ _gdk_x11_surface_drag_begin (GdkSurface         *surface,
                                    NULL);
   x11_drag = GDK_X11_DRAG (drag);
 
-  g_signal_connect (display, "xevent", G_CALLBACK (gdk_x11_drag_xevent), drag);
-
   precache_target_list (drag);
 
   gdk_device_get_position (device, &px, &py);
@@ -2115,6 +2113,8 @@ _gdk_x11_surface_drag_begin (GdkSurface         *surface,
       return NULL;
     }
 
+  g_signal_connect_object (display, "xevent", G_CALLBACK (gdk_x11_drag_xevent), drag, 0);
+
   return drag;
 }
 


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