[gtk+] widget: Take a ref during ::unrealize emission



commit b4e61b759ba9c0782ff7fd592046f46022ca471e
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Mar 16 16:20:21 2015 +0100

    widget: Take a ref during ::unrealize emission
    
    In order to prevent invalid memory access/crashes if the widget is
    destroyed in a callback of that signal.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=745829

 gtk/gtkwidget.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 043fac4..5e0a9cb 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -5566,6 +5566,7 @@ gtk_widget_unrealize (GtkWidget *widget)
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
+  g_object_ref (widget);
   gtk_widget_push_verify_invariants (widget);
 
   if (widget->priv->has_shape_mask)
@@ -5592,6 +5593,7 @@ gtk_widget_unrealize (GtkWidget *widget)
     }
 
   gtk_widget_pop_verify_invariants (widget);
+  g_object_unref (widget);
 }
 
 /*****************************************


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