From 833b56494692aa683144259852dd960691f6f033 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 22 Feb 2020 17:44:36 -0500 Subject: [PATCH] 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; }