[gtk/gtk-4-2: 90/91] dragsource: Keep the source alive long enough
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gtk-4-2: 90/91] dragsource: Keep the source alive long enough
- Date: Tue, 4 May 2021 02:05:42 +0000 (UTC)
commit 2f921ab66795c947d75ab269412f9c73abf88508
Author: Matthias Clasen <mclasen redhat com>
Date: Mon May 3 17:00:17 2021 -0400
dragsource: Keep the source alive long enough
When a drop causes the event controller to be finalized
(directly or indirectly), we end up segfaulting while
trying to wrap up the drag operation. So, keep a reference
on the GtkDragSource from when the drag begins to when
it is done.
This fixes a crash in gnome-todo when dragging tasks.
gtk/gtkdragsource.c | 4 ++++
1 file changed, 4 insertions(+)
---
diff --git a/gtk/gtkdragsource.c b/gtk/gtkdragsource.c
index cd6c33a7fa..a75f60f5c2 100644
--- a/gtk/gtkdragsource.c
+++ b/gtk/gtkdragsource.c
@@ -470,6 +470,7 @@ drag_end (GtkDragSource *source,
gdk_drag_drop_done (source->drag, success);
g_clear_object (&source->drag);
+ g_object_unref (source);
}
static void
@@ -593,6 +594,9 @@ gtk_drag_source_drag_begin (GtkDragSource *source)
gtk_drag_source_ensure_icon (source, source->drag);
+ /* Keep the source alive until the drag is done */
+ g_object_ref (source);
+
g_signal_connect (source->drag, "dnd-finished",
G_CALLBACK (gtk_drag_source_dnd_finished_cb), source);
g_signal_connect (source->drag, "cancel",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]