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.
This commit is contained in:
parent
f55afb6542
commit
bb224bafd0
|
@ -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");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -803,12 +803,19 @@ ld_diagram_end_user_action (LdDiagram *self)
|
|||
(self->priv->undo_stack, self->priv->undo_stack);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
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);
|
||||
if (g_slist_find (self->priv->subcategories, category))
|
||||
{
|
||||
self->priv->subcategories
|
||||
= g_slist_remove (self->priv->subcategories, category);
|
||||
g_object_unref (category);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue