diff options
author | Jonas Ådahl <jadahl@gmail.com> | 2015-08-03 14:26:39 +0800 |
---|---|---|
committer | Jonas Ådahl <jadahl@gmail.com> | 2015-08-05 10:31:55 +0800 |
commit | 27763743b1d1c1900932099ff10e64f4a2734148 (patch) | |
tree | 8c8b8c0f8f3b38758b74d4a7f69ddb4021969189 | |
parent | 69c9cb85e2dfb5169a7d3b71b4ef7e9203126a83 (diff) | |
download | gtk+-27763743b1d1c1900932099ff10e64f4a2734148.tar.gz |
wayland: Don't assume drag context has a source window when finalizing
Only a drag context which was created with 'drag_begin' will be
guaranteed to have a source window at all times. Thus, in finalize we
cannot assume we can retrieve a GdkDisplay from the source_window
pointer since it may be NULL. Though, the display is only needed for
contexts created via 'drag_begin' thus we can retrieve it after
checking that is the case.
https://bugzilla.gnome.org/show_bug.cgi?id=749339
-rw-r--r-- | gdk/wayland/gdkdnd-wayland.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/gdk/wayland/gdkdnd-wayland.c b/gdk/wayland/gdkdnd-wayland.c index e96aeda337..835b6d08e2 100644 --- a/gdk/wayland/gdkdnd-wayland.c +++ b/gdk/wayland/gdkdnd-wayland.c @@ -64,13 +64,20 @@ gdk_wayland_drag_context_finalize (GObject *object) { GdkWaylandDragContext *wayland_context = GDK_WAYLAND_DRAG_CONTEXT (object); GdkDragContext *context = GDK_DRAG_CONTEXT (object); - GdkDisplay *display = gdk_window_get_display (context->source_window); contexts = g_list_remove (contexts, context); - if (context->is_source && - gdk_selection_owner_get_for_display (display, gdk_drag_get_selection (context)) == context->source_window) - gdk_wayland_selection_unset_data_source (display, gdk_drag_get_selection (context)); + if (context->is_source) + { + GdkDisplay *display = gdk_window_get_display (context->source_window); + GdkAtom selection; + GdkWindow *selection_owner; + + selection = gdk_drag_get_selection (context); + selection_owner = gdk_selection_owner_get_for_display (display, selection); + if (selection_owner == context->source_window) + gdk_wayland_selection_unset_data_source (display, selection); + } if (wayland_context->data_source) wl_data_source_destroy (wayland_context->data_source); |