From 163b2d040361b15420bec152655b6a57a514ab1f Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Wed, 10 Mar 2010 18:22:06 -0500 Subject: [PATCH] Fixes for dispose and finalize * Add missing chain-up for dispose and finalize methods * ShellGenericContainer needs to destroy its children in dispose() * Fix variable naming and excess casts in st_label_dispose() https://bugzilla.gnome.org/show_bug.cgi?id=612511 --- src/shell-app.c | 2 ++ src/shell-generic-container.c | 12 ++++++++++++ src/st/st-drawing-area.c | 2 ++ src/st/st-entry.c | 4 ++++ src/st/st-im-text.c | 2 ++ src/st/st-label.c | 6 +++--- 6 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/shell-app.c b/src/shell-app.c index 992ad8bd8..7630cd0c3 100644 --- a/src/shell-app.c +++ b/src/shell-app.c @@ -360,6 +360,8 @@ shell_app_dispose (GObject *object) _shell_app_remove_window (app, app->windows->data); disconnect_workspace_switch (app); + + G_OBJECT_CLASS(shell_app_parent_class)->dispose (object); } static void diff --git a/src/shell-generic-container.c b/src/shell-generic-container.c index ad34fee47..16b285dcd 100644 --- a/src/shell-generic-container.c +++ b/src/shell-generic-container.c @@ -228,6 +228,17 @@ shell_generic_container_finalize (GObject *object) G_OBJECT_CLASS (shell_generic_container_parent_class)->finalize (object); } +static void +shell_generic_container_dispose (GObject *object) +{ + ShellGenericContainerPrivate *priv = SHELL_GENERIC_CONTAINER (object)->priv; + + while (priv->children) + clutter_actor_destroy (priv->children->data); + + G_OBJECT_CLASS (shell_generic_container_parent_class)->dispose (object); +} + static void shell_generic_container_class_init (ShellGenericContainerClass *klass) { @@ -235,6 +246,7 @@ shell_generic_container_class_init (ShellGenericContainerClass *klass) ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); gobject_class->finalize = shell_generic_container_finalize; + gobject_class->dispose = shell_generic_container_dispose; actor_class->get_preferred_width = shell_generic_container_get_preferred_width; actor_class->get_preferred_height = shell_generic_container_get_preferred_height; diff --git a/src/st/st-drawing-area.c b/src/st/st-drawing-area.c index 720c4003d..7115655cd 100644 --- a/src/st/st-drawing-area.c +++ b/src/st/st-drawing-area.c @@ -63,6 +63,8 @@ st_drawing_area_dispose (GObject *object) cogl_handle_unref (priv->texture); priv->texture = COGL_INVALID_HANDLE; } + + G_OBJECT_CLASS (st_drawing_area_parent_class)->dispose (object); } static void diff --git a/src/st/st-entry.c b/src/st/st-entry.c index fa1048932..147640d7e 100644 --- a/src/st/st-entry.c +++ b/src/st/st-entry.c @@ -171,6 +171,8 @@ st_entry_dispose (GObject *object) clutter_actor_destroy (priv->entry); priv->entry = NULL; } + + G_OBJECT_CLASS (st_entry_parent_class)->dispose (object); } static void @@ -180,6 +182,8 @@ st_entry_finalize (GObject *object) g_free (priv->hint); priv->hint = NULL; + + G_OBJECT_CLASS (st_entry_parent_class)->finalize (object); } static void diff --git a/src/st/st-im-text.c b/src/st/st-im-text.c index aa94b4058..29fd71e4d 100644 --- a/src/st/st-im-text.c +++ b/src/st/st-im-text.c @@ -93,6 +93,8 @@ st_im_text_dispose (GObject *object) g_object_unref (priv->im_context); priv->im_context = NULL; + + G_OBJECT_CLASS (st_im_text_parent_class)->dispose (object); } static void diff --git a/src/st/st-label.c b/src/st/st-label.c index 1a304a4bf..0b6a9fd23 100644 --- a/src/st/st-label.c +++ b/src/st/st-label.c @@ -172,9 +172,9 @@ st_label_allocate (ClutterActor *actor, } static void -st_label_dispose (GObject *actor) +st_label_dispose (GObject *object) { - StLabelPrivate *priv = ST_LABEL (actor)->priv; + StLabelPrivate *priv = ST_LABEL (object)->priv; if (priv->label) { @@ -182,7 +182,7 @@ st_label_dispose (GObject *actor) priv->label = NULL; } - G_OBJECT_CLASS (st_label_parent_class)->dispose (G_OBJECT (actor)); + G_OBJECT_CLASS (st_label_parent_class)->dispose (object); } static void