[glade3/glade-3-8] Moved unparenting of all widgets back to GladeProject at dispose time.
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade3/glade-3-8] Moved unparenting of all widgets back to GladeProject at dispose time.
- Date: Mon, 20 Dec 2010 02:31:10 +0000 (UTC)
commit 301a3aa6dea7fcbdb0961d9effa8cfdc2485d163
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Mon Dec 20 11:35:37 2010 +0900
Moved unparenting of all widgets back to GladeProject at dispose time.
This ensures that the deepest children are finalized first.
gladeui/glade-project.c | 41 +++++++++++++++++++++++++++++++++++++++++
gladeui/glade-widget.c | 19 ++-----------------
2 files changed, 43 insertions(+), 17 deletions(-)
---
diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c
index 8d73dc2..204fce9 100644
--- a/gladeui/glade-project.c
+++ b/gladeui/glade-project.c
@@ -258,6 +258,34 @@ glade_project_list_unref (GList *original_list)
}
static void
+unparent_objects_recurse (GladeWidget *widget)
+{
+ GladeWidget *child;
+ GList *children, *list;
+
+ /* Unparent all children */
+ if ((children =
+ glade_widget_get_children (widget)) != NULL)
+ {
+ for (list = children; list; list = list->next)
+ {
+ child = glade_widget_get_from_gobject (list->data);
+
+ unparent_objects_recurse (child);
+
+ if (child->internal == NULL)
+ {
+ g_print ("Project dispose unreffing %s's child %s\n",
+ widget->name, child->name);
+
+ glade_widget_remove_child (widget, child);
+ }
+ }
+ g_list_free (children);
+ }
+}
+
+static void
glade_project_dispose (GObject *object)
{
GladeProject *project = GLADE_PROJECT (object);
@@ -274,9 +302,22 @@ glade_project_dispose (GObject *object)
/* Remove objects from the project */
tree = g_list_copy (project->priv->tree);
for (list = tree; list; list = list->next)
+ {
+ GladeWidget *gwidget = glade_widget_get_from_gobject (list->data);
+
+ g_object_ref (gwidget);
+
glade_project_remove_object (project, list->data);
+
+ unparent_objects_recurse (gwidget);
+
+ g_object_unref (gwidget);
+ }
g_list_free (tree);
+ g_assert (project->priv->tree == NULL);
+ g_assert (project->priv->objects == NULL);
+
G_OBJECT_CLASS (glade_project_parent_class)->dispose (object);
}
diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c
index ac67f1b..415bf0a 100644
--- a/gladeui/glade-widget.c
+++ b/gladeui/glade-widget.c
@@ -168,9 +168,9 @@ glade_widget_remove_child_impl (GladeWidget *widget,
glade_widget_adaptor_remove
(widget->adaptor, widget->object, child->object);
- g_object_unref (child);
-
child->parent = NULL;
+
+ g_object_unref (child);
}
static void
@@ -855,20 +855,6 @@ glade_widget_dispose (GObject *object)
glade_widget_push_superuser ();
- /* Unparent all children */
- if ((children =
- glade_widget_get_children (widget)) != NULL)
- {
- for (list = children; list; list = list->next)
- {
- child = glade_widget_get_from_gobject (list->data);
-
- if (child->internal == NULL)
- glade_widget_remove_child (widget, child);
- }
- g_list_free (children);
- }
-
/* Release references by way of object properties... */
while (widget->prop_refs)
{
@@ -3384,7 +3370,6 @@ glade_widget_set_object (GladeWidget *gwidget, GObject *new_object, gboolean des
if (gwidget->internal == NULL)
{
-
#if _YOU_WANT_TO_LOOK_AT_PROJECT_REFCOUNT_BALANCING_
g_print ("Killing '%s::%s' widget's object with reference count %d\n",
gwidget->adaptor->name, gwidget->name ? gwidget->name : "(unknown)",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]