[gtk+/gtk-3-14] widget: Take a ref during ::unrealize emission
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-14] widget: Take a ref during ::unrealize emission
- Date: Mon, 23 Mar 2015 03:32:23 +0000 (UTC)
commit ea7361c1480080c45e2693578ca459b981732032
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 | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 1850c59..d1395e3 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -5553,6 +5553,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)
@@ -5563,8 +5564,6 @@ gtk_widget_unrealize (GtkWidget *widget)
if (gtk_widget_get_realized (widget))
{
- g_object_ref (widget);
-
if (widget->priv->mapped)
gtk_widget_unmap (widget);
@@ -5574,11 +5573,10 @@ gtk_widget_unrealize (GtkWidget *widget)
g_signal_emit (widget, widget_signals[UNREALIZE], 0);
g_assert (!widget->priv->mapped);
gtk_widget_set_realized (widget, FALSE);
-
- g_object_unref (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]