aboutsummaryrefslogtreecommitdiff
path: root/hildon/hildon-time-selector.c
diff options
context:
space:
mode:
authorAlberto Garcia <agarcia@igalia.com>2009-10-05 20:42:22 +0200
committerAlberto Garcia <agarcia@igalia.com>2009-10-05 20:42:22 +0200
commit2942c0e43a2121c330711af4bcd9f00c8feabdab (patch)
tree8ef71eeb9a20247e3e924579bce95aa10911e891 /hildon/hildon-time-selector.c
parent9378c91d251bd418e0553935a027988e2b6ae230 (diff)
Fix memory leak in HildonTimeSelector
* hildon/hildon-time-selector.c (update_format_dependant_columns, hildon_time_selector_finalize): Don't leak the tree models.
Diffstat (limited to 'hildon/hildon-time-selector.c')
-rw-r--r--hildon/hildon-time-selector.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/hildon/hildon-time-selector.c b/hildon/hildon-time-selector.c
index bf6ff13..e5188e5 100644
--- a/hildon/hildon-time-selector.c
+++ b/hildon/hildon-time-selector.c
@@ -313,10 +313,22 @@ hildon_time_selector_set_property (GObject *object,
static void
hildon_time_selector_finalize (GObject * object)
{
- /* Note: we don't require to free the models. We don't manage it using own
- references, so will be freed on the hildon-touch-selector finalize code.
- See the implementation notes related to that on the touch selector
- code. */
+ HildonTimeSelectorPrivate *priv = HILDON_TIME_SELECTOR_GET_PRIVATE (object);
+
+ if (priv->hours_model) {
+ g_object_unref (priv->hours_model);
+ priv->hours_model = NULL;
+ }
+
+ if (priv->minutes_model) {
+ g_object_unref (priv->minutes_model);
+ priv->minutes_model = NULL;
+ }
+
+ if (priv->ampm_model) {
+ g_object_unref (priv->ampm_model);
+ priv->ampm_model = NULL;
+ }
(*G_OBJECT_CLASS (hildon_time_selector_parent_class)->finalize) (object);
}
@@ -562,6 +574,9 @@ update_format_dependant_columns (HildonTimeSelector *selector,
/* To avoid an extra and wrong VALUE_CHANGED signal on the model update */
hildon_touch_selector_block_changed (HILDON_TOUCH_SELECTOR(selector));
+ if (selector->priv->hours_model) {
+ g_object_unref (selector->priv->hours_model);
+ }
selector->priv->hours_model = _create_hours_model (selector);
hildon_touch_selector_set_model (HILDON_TOUCH_SELECTOR (selector),
0,
@@ -577,6 +592,9 @@ update_format_dependant_columns (HildonTimeSelector *selector,
/* if we are at this function, we are sure that a change on the number of columns
will happen, so check the column number is not required */
+ if (selector->priv->ampm_model) {
+ g_object_unref (selector->priv->ampm_model);
+ }
if (selector->priv->ampm_format) {
selector->priv->ampm_model = _create_ampm_model (selector);