wayland: Fix thinko in wl_data_source.cancelled handler
authorCarlos Garnacho <carlosg@gnome.org>
Tue, 17 Mar 2015 16:59:15 +0000 (17:59 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Wed, 18 Mar 2015 10:21:40 +0000 (11:21 +0100)
The wl_data_source may be the clipboard's. Looking up the drag context in
order to get the display isn't going to fare well there. So, just use the
default display, and only look up the drag context when we know we need it.

https://bugzilla.gnome.org/show_bug.cgi?id=746386

gdk/wayland/gdkselection-wayland.c

index 39a5f22c195b3ada9250ab7af2bcaeaec2f470af..651785a3ed7f71d3c6b2f97d8da1d0be9f20ab33 100644 (file)
@@ -668,16 +668,19 @@ data_source_cancelled (void                  *data,
   g_debug (G_STRLOC ": %s source = %p",
            G_STRFUNC, source);
 
-  context = gdk_wayland_drag_context_lookup_by_data_source (source);
-  display = gdk_window_get_display (context->source_window);
+  display = gdk_display_get_default ();
 
   if (source == wayland_selection->dnd_source)
-    gdk_wayland_selection_unset_data_source (display, atoms[ATOM_DND]);
+    {
+      gdk_wayland_selection_unset_data_source (display, atoms[ATOM_DND]);
+
+      context = gdk_wayland_drag_context_lookup_by_data_source (source);
+
+      if (context)
+        gdk_wayland_drag_context_undo_grab (context);
+    }
   else if (source == wayland_selection->clipboard_source)
     gdk_wayland_selection_unset_data_source (display, atoms[ATOM_CLIPBOARD]);
-
-  if (context)
-    gdk_wayland_drag_context_undo_grab (context);
 }
 
 static const struct wl_data_source_listener data_source_listener = {