From: Timm Bäder Date: Wed, 2 Oct 2019 10:00:43 +0000 (+0200) Subject: widget: Create finalize assertions in destroy() X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~20^2~775 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=d8c940325c65cddde959676fdabd8ff9d700f51a;p=gtk4.git widget: Create finalize assertions in destroy() --- diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 51a2794feb..8880faba97 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -7922,35 +7922,6 @@ finalize_assertion_weak_ref (gpointer data, FinalizeAssertion *assertion = (FinalizeAssertion *)data; assertion->did_finalize = TRUE; } - -static FinalizeAssertion * -finalize_assertion_new (GtkWidget *widget, - GType widget_type, - AutomaticChildClass *child_class) -{ - FinalizeAssertion *assertion = NULL; - GObject *object; - - object = gtk_widget_get_template_child (widget, widget_type, child_class->name); - - /* We control the hash table entry, the object should never be NULL - */ - g_assert (object); - if (!G_IS_OBJECT (object)) - g_critical ("Automated component '%s' of class '%s' seems to have been prematurely finalized", - child_class->name, g_type_name (widget_type)); - else - { - assertion = g_slice_new0 (FinalizeAssertion); - assertion->child_class = child_class; - assertion->widget_type = widget_type; - assertion->object = object; - - g_object_weak_ref (object, finalize_assertion_weak_ref, assertion); - } - - return assertion; -} #endif /* G_ENABLE_CONSISTENCY_CHECKS */ static void @@ -7993,10 +7964,29 @@ gtk_widget_real_destroy (GtkWidget *object) for (l = class->priv->template->children; l; l = l->next) { AutomaticChildClass *child_class = l->data; - FinalizeAssertion *assertion; + GObject *child_object = gtk_widget_get_template_child (widget, + class_type, + child_class->name); + + g_assert (child_object); - assertion = finalize_assertion_new (widget, class_type, child_class); - assertions = g_slist_prepend (assertions, assertion); + if (!G_IS_OBJECT (child_object)) + { + g_critical ("Automated component '%s' of class '%s' seems to" + " have been prematurely finalized", + child_class->name, g_type_name (class_type)); + } + else + { + FinalizeAssertion *assertion = g_slice_new0 (FinalizeAssertion); + assertion->child_class = child_class; + assertion->widget_type = class_type; + assertion->object = child_object; + + g_object_weak_ref (child_object, finalize_assertion_weak_ref, assertion); + + assertions = g_slist_prepend (assertions, assertion); + } } } }