[gtk/wip/otte/widgetfactory-dnd: 1/6] dnd: Guard drags with a reference when finishing
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/widgetfactory-dnd: 1/6] dnd: Guard drags with a reference when finishing
- Date: Mon, 26 Jul 2021 00:36:20 +0000 (UTC)
commit f5dc71021fc3adc0c13e7ab8b3f9e78e434bacdb
Author: Benjamin Otte <otte redhat com>
Date: Mon Jul 26 02:16:47 2021 +0200
dnd: Guard drags with a reference when finishing
Usually the "dnd-finished" signal will be used to unref the GdkDrag. In
those cases, we would lose the object, so that when we do the final
drag_drop_done() afterwards, we wouldn't have a remaining reference.
With the reference guard, this now works.
gdk/macos/gdkmacosdrag.c | 2 ++
gdk/wayland/gdkdrag-wayland.c | 2 ++
gdk/x11/gdkdrag-x11.c | 2 ++
3 files changed, 6 insertions(+)
---
diff --git a/gdk/macos/gdkmacosdrag.c b/gdk/macos/gdkmacosdrag.c
index ee4b5e7020..0eb246bd0b 100644
--- a/gdk/macos/gdkmacosdrag.c
+++ b/gdk/macos/gdkmacosdrag.c
@@ -242,9 +242,11 @@ gdk_macos_drag_drop_performed (GdkDrag *drag,
g_assert (GDK_IS_MACOS_DRAG (self));
+ g_object_ref (self);
drag_ungrab (self);
g_signal_emit_by_name (drag, "dnd-finished");
gdk_drag_drop_done (drag, TRUE);
+ g_object_unref (self);
}
static void
diff --git a/gdk/wayland/gdkdrag-wayland.c b/gdk/wayland/gdkdrag-wayland.c
index 8a8c4cc058..55521353c3 100644
--- a/gdk/wayland/gdkdrag-wayland.c
+++ b/gdk/wayland/gdkdrag-wayland.c
@@ -290,8 +290,10 @@ data_source_dnd_finished (void *data,
{
GdkDrag *drag = data;
+ g_object_ref (drag);
g_signal_emit_by_name (drag, "dnd-finished");
gdk_drag_drop_done (drag, TRUE);
+ g_object_unref (drag);
}
static void
diff --git a/gdk/x11/gdkdrag-x11.c b/gdk/x11/gdkdrag-x11.c
index 88e65a2a2c..f4b752306e 100644
--- a/gdk/x11/gdkdrag-x11.c
+++ b/gdk/x11/gdkdrag-x11.c
@@ -884,8 +884,10 @@ gdk_x11_drag_handle_finished (GdkDisplay *display,
if (drag_x11->version == 5)
drag_x11->drop_failed = xevent->xclient.data.l[1] == 0;
+ g_object_ref (drag);
g_signal_emit_by_name (drag, "dnd-finished");
gdk_drag_drop_done (drag, !drag_x11->drop_failed);
+ g_object_unref (drag);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]