summaryrefslogtreecommitdiff
path: root/0001-eventcontroller-Ensure-controllers-stay-alive-during.patch
blob: 9552188ab4a8dac92f87ba1c229a497d2293128c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
From 618e3d31570fca577cf374d7b318bc7ca44cadb1 Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Wed, 28 May 2014 19:39:07 +0200
Subject: [PATCH] eventcontroller: Ensure controllers stay alive during event
 emission

Those might trigger the destruction of some widget that would dispose the
event controller while the event is still being handled, so keep an extra
ref on the controller during event processing.
---
 gtk/gtkeventcontroller.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gtk/gtkeventcontroller.c b/gtk/gtkeventcontroller.c
index b674380..c0b828f 100644
--- a/gtk/gtkeventcontroller.c
+++ b/gtk/gtkeventcontroller.c
@@ -205,7 +205,11 @@ gtk_event_controller_handle_event (GtkEventController *controller,
   controller_class = GTK_EVENT_CONTROLLER_GET_CLASS (controller);
 
   if (controller_class->handle_event)
-    retval = controller_class->handle_event (controller, event);
+    {
+      g_object_ref (controller);
+      retval = controller_class->handle_event (controller, event);
+      g_object_unref (controller);
+    }
 
   return retval;
 }
-- 
2.0.0

bgstack15