[gtk/gtk-4-4] gtk: Hold reference on controller until events are fully handled



commit f41d98d104762133c6dcf6aa8194b8a5a36f18fc
Author: Maxim Zakharov <zakhma muli com au>
Date:   Wed Oct 27 11:37:36 2021 +1100

    gtk: Hold reference on controller until events are fully handled
    
    Fixes premature controller unreferencing in
    gtk_event_controller_handle_event() if the controller itself is being
    removed while handling the event.

 gtk/gtkeventcontroller.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/gtk/gtkeventcontroller.c b/gtk/gtkeventcontroller.c
index 6892562901..2d0de55383 100644
--- a/gtk/gtkeventcontroller.c
+++ b/gtk/gtkeventcontroller.c
@@ -367,10 +367,10 @@ gtk_event_controller_handle_event (GtkEventController *controller,
 
   g_object_ref (controller);
   retval = controller_class->handle_event (controller, event, x, y);
-  g_object_unref (controller);
 
   g_clear_object (&priv->target);
   g_clear_pointer (&priv->event, gdk_event_unref);
+  g_object_unref (controller);
 
   return retval;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]