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.
This commit is contained in:
Matthias Clasen 2020-02-22 17:44:36 -05:00
parent 7edfcc37a3
commit 833b564946

View File

@ -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;
}