From c98cea3dbbdb6b3c37a4a04ae0881e6e0fc76132 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 27 Sep 2022 03:44:41 +0200 Subject: [PATCH] drop target: Warn about broken signal handler returns Signal handlers ust return their preferred action and that one must be unique. Shout at them if they don't do that, before gdk_drop_status() does tesame thing. Related: gnome-build-meta#554 Related: gnome-builder#1799 --- gtk/gtkdroptarget.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gtk/gtkdroptarget.c b/gtk/gtkdroptarget.c index 31ca55f950..d3d834d70e 100644 --- a/gtk/gtkdroptarget.c +++ b/gtk/gtkdroptarget.c @@ -430,6 +430,12 @@ gtk_drop_target_handle_event (GtkEventController *controller, graphene_point_init (&self->coords, x, y); g_signal_emit (self, signals[MOTION], 0, x, y, &preferred); + if (!gdk_drag_action_is_unique (preferred)) + { + g_critical ("Handler for GtkDropTarget::motion on %s %p did not return a unique preferred action", + G_OBJECT_TYPE_NAME (widget), widget); + preferred = make_action_unique (preferred); + } if (preferred && gtk_drop_status (self->drop, self->actions, preferred)) { @@ -497,6 +503,12 @@ gtk_drop_target_handle_crossing (GtkEventController *controller, gtk_drop_target_start_drop (self, crossing->drop); g_signal_emit (self, signals[ENTER], 0, x, y, &preferred); + if (!gdk_drag_action_is_unique (preferred)) + { + g_critical ("Handler for GtkDropTarget::enter on %s %p did not return a unique preferred action", + G_OBJECT_TYPE_NAME (widget), widget); + preferred = make_action_unique (preferred); + } if (preferred && gtk_drop_status (self->drop, self->actions, preferred)) {