summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2012-08-11 21:00:38 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2012-08-12 01:01:13 +0200
commitbb224bafd043e07fd18e3d8cda2c3f41c132e507 (patch)
tree2332e4a1228bb43324ce56bc8253595e979ee11f
parentf55afb6542b9eb39e56a32dc8a18002ad680ad41 (diff)
downloadlogdiag-bb224bafd043e07fd18e3d8cda2c3f41c132e507.tar.gz
logdiag-bb224bafd043e07fd18e3d8cda2c3f41c132e507.tar.xz
logdiag-bb224bafd043e07fd18e3d8cda2c3f41c132e507.zip
More fixing.
* Fix a resource leak in LdLibrary. * Add missing property change notifiers to ld_diagram_object_{get,set}_storage(). * Don't unref the parameter in ld_symbol_category_remove_{symbol,subcategory} if it wasn't actually removed from the internal list. * Fix a cyclic dependency problem in LdDiagram.
-rw-r--r--liblogdiag/ld-diagram-object.c6
-rw-r--r--liblogdiag/ld-diagram.c19
-rw-r--r--liblogdiag/ld-library.c3
-rw-r--r--liblogdiag/ld-symbol-category.c16
4 files changed, 36 insertions, 8 deletions
diff --git a/liblogdiag/ld-diagram-object.c b/liblogdiag/ld-diagram-object.c
index 684e93f..ba2c1f6 100644
--- a/liblogdiag/ld-diagram-object.c
+++ b/liblogdiag/ld-diagram-object.c
@@ -221,8 +221,12 @@ JsonObject *
ld_diagram_object_get_storage (LdDiagramObject *self)
{
g_return_val_if_fail (LD_IS_DIAGRAM_OBJECT (self), NULL);
+
if (!self->priv->storage)
+ {
self->priv->storage = json_object_new ();
+ g_object_notify (G_OBJECT (self), "storage");
+ }
return self->priv->storage;
}
@@ -245,6 +249,8 @@ ld_diagram_object_set_storage (LdDiagramObject *self, JsonObject *storage)
self->priv->storage = json_object_ref (storage);
else
self->priv->storage = NULL;
+
+ g_object_notify (G_OBJECT (self), "storage");
}
/**
diff --git a/liblogdiag/ld-diagram.c b/liblogdiag/ld-diagram.c
index cd483ec..46f94df 100644
--- a/liblogdiag/ld-diagram.c
+++ b/liblogdiag/ld-diagram.c
@@ -804,11 +804,18 @@ ld_diagram_end_user_action (LdDiagram *self)
}
static void
+action_finalize_notify_cb (ObjectActionData *data, LdDiagram *self)
+{
+ data->self = NULL;
+}
+
+static void
on_object_action_remove (gpointer user_data)
{
ObjectActionData *data;
data = user_data;
+ g_return_if_fail (data->self != NULL);
ld_diagram_remove_object (data->self, data->object);
}
@@ -818,6 +825,7 @@ on_object_action_insert (gpointer user_data)
ObjectActionData *data;
data = user_data;
+ g_return_if_fail (data->self != NULL);
ld_diagram_insert_object (data->self, data->object, data->pos);
}
@@ -827,7 +835,8 @@ on_object_action_destroy (gpointer user_data)
ObjectActionData *data;
data = user_data;
- g_object_unref (data->self);
+ g_object_weak_unref (G_OBJECT (data->self),
+ (GWeakNotify) action_finalize_notify_cb, data);
g_object_unref (data->object);
g_slice_free (ObjectActionData, data);
}
@@ -891,7 +900,9 @@ ld_diagram_insert_object (LdDiagram *self, LdDiagramObject *object, gint pos)
install_object (object, self);
action_data = g_slice_new (ObjectActionData);
- action_data->self = g_object_ref (self);
+ action_data->self = self;
+ g_object_weak_ref (G_OBJECT (self),
+ (GWeakNotify) action_finalize_notify_cb, action_data);
action_data->object = g_object_ref (object);
action_data->pos = pos;
@@ -938,7 +949,9 @@ ld_diagram_remove_object (LdDiagram *self, LdDiagramObject *object)
uninstall_object (object, self);
action_data = g_slice_new (ObjectActionData);
- action_data->self = g_object_ref (self);
+ action_data->self = self;
+ g_object_weak_ref (G_OBJECT (self),
+ (GWeakNotify) action_finalize_notify_cb, action_data);
action_data->object = g_object_ref (object);
action_data->pos = pos;
diff --git a/liblogdiag/ld-library.c b/liblogdiag/ld-library.c
index 13242a1..8f07720 100644
--- a/liblogdiag/ld-library.c
+++ b/liblogdiag/ld-library.c
@@ -378,7 +378,10 @@ ld_library_load_cb (const gchar *base, const gchar *filename, gpointer userdata)
cat = load_category (data->self, filename, base);
if (cat)
+ {
ld_library_insert_category (data->self, cat, -1);
+ g_object_unref (cat);
+ }
data->changed = TRUE;
return TRUE;
diff --git a/liblogdiag/ld-symbol-category.c b/liblogdiag/ld-symbol-category.c
index d8150dc..4c35c4c 100644
--- a/liblogdiag/ld-symbol-category.c
+++ b/liblogdiag/ld-symbol-category.c
@@ -325,8 +325,11 @@ ld_symbol_category_remove_symbol (LdSymbolCategory *self,
g_return_if_fail (LD_IS_SYMBOL_CATEGORY (self));
g_return_if_fail (LD_IS_SYMBOL (symbol));
- g_object_unref (symbol);
- self->priv->symbols = g_slist_remove (self->priv->symbols, symbol);
+ if (g_slist_find (self->priv->symbols, symbol))
+ {
+ self->priv->symbols = g_slist_remove (self->priv->symbols, symbol);
+ g_object_unref (symbol);
+ }
}
/**
@@ -378,9 +381,12 @@ ld_symbol_category_remove_subcategory (LdSymbolCategory *self,
g_return_if_fail (LD_IS_SYMBOL_CATEGORY (self));
g_return_if_fail (LD_IS_SYMBOL_CATEGORY (category));
- g_object_unref (category);
- self->priv->subcategories
- = g_slist_remove (self->priv->subcategories, category);
+ if (g_slist_find (self->priv->subcategories, category))
+ {
+ self->priv->subcategories
+ = g_slist_remove (self->priv->subcategories, category);
+ g_object_unref (category);
+ }
}
/**