Clean up LdDiagram.

* Don't emit signals when disposing.
* Remove some leftovers.
This commit is contained in:
Přemysl Eric Janouch 2012-10-07 23:42:49 +02:00
parent 4196a10ece
commit 6c925b7092
1 changed files with 20 additions and 19 deletions

View File

@ -31,7 +31,6 @@
* each containing a #GList of #LdUndoAction subactions. * each containing a #GList of #LdUndoAction subactions.
* @objects: all objects in the diagram. * @objects: all objects in the diagram.
* @selection: all currently selected objects. * @selection: all currently selected objects.
* @connections: connections between objects.
*/ */
struct _LdDiagramPrivate struct _LdDiagramPrivate
{ {
@ -43,7 +42,6 @@ struct _LdDiagramPrivate
GList *objects; GList *objects;
GList *selection; GList *selection;
GList *connections;
}; };
typedef struct _ObjectActionData ObjectActionData; typedef struct _ObjectActionData ObjectActionData;
@ -76,6 +74,7 @@ static void ld_diagram_set_property (GObject *object, guint property_id,
static void ld_diagram_dispose (GObject *gobject); static void ld_diagram_dispose (GObject *gobject);
static void ld_diagram_finalize (GObject *gobject); static void ld_diagram_finalize (GObject *gobject);
static void ld_diagram_real_changed (LdDiagram *self); static void ld_diagram_real_changed (LdDiagram *self);
static void ld_diagram_clear_internal (LdDiagram *self, gboolean emit_signals);
static gboolean write_signature (GOutputStream *stream, GError **error); static gboolean write_signature (GOutputStream *stream, GError **error);
@ -232,7 +231,7 @@ ld_diagram_dispose (GObject *gobject)
LdDiagram *self; LdDiagram *self;
self = LD_DIAGRAM (gobject); self = LD_DIAGRAM (gobject);
ld_diagram_clear (self); ld_diagram_clear_internal (self, FALSE);
/* Chain up to the parent class. */ /* Chain up to the parent class. */
G_OBJECT_CLASS (ld_diagram_parent_class)->dispose (gobject); G_OBJECT_CLASS (ld_diagram_parent_class)->dispose (gobject);
@ -286,24 +285,23 @@ ld_diagram_new (void)
*/ */
void void
ld_diagram_clear (LdDiagram *self) ld_diagram_clear (LdDiagram *self)
{
g_return_if_fail (LD_IS_DIAGRAM (self));
ld_diagram_clear_internal (self, TRUE);
}
static void
ld_diagram_clear_internal (LdDiagram *self, gboolean emit_signals)
{ {
gboolean changed = FALSE; gboolean changed = FALSE;
gboolean selection_changed = FALSE; gboolean selection_changed = FALSE;
g_return_if_fail (LD_IS_DIAGRAM (self));
if (self->priv->selection) if (self->priv->selection)
{ {
ld_diagram_unselect_all_internal (self); ld_diagram_unselect_all_internal (self);
selection_changed = TRUE; selection_changed = TRUE;
} }
if (self->priv->connections)
{
g_list_free (self->priv->connections);
self->priv->connections = NULL;
changed = TRUE;
}
if (self->priv->objects) if (self->priv->objects)
{ {
g_list_foreach (self->priv->objects, (GFunc) uninstall_object, self); g_list_foreach (self->priv->objects, (GFunc) uninstall_object, self);
@ -315,6 +313,8 @@ ld_diagram_clear (LdDiagram *self)
destroy_action_stack (&self->priv->undo_stack); destroy_action_stack (&self->priv->undo_stack);
destroy_action_stack (&self->priv->redo_stack); destroy_action_stack (&self->priv->redo_stack);
if (emit_signals)
{
g_object_notify (G_OBJECT (self), "can-undo"); g_object_notify (G_OBJECT (self), "can-undo");
g_object_notify (G_OBJECT (self), "can-redo"); g_object_notify (G_OBJECT (self), "can-redo");
@ -325,6 +325,7 @@ ld_diagram_clear (LdDiagram *self)
g_signal_emit (self, g_signal_emit (self,
LD_DIAGRAM_GET_CLASS (self)->selection_changed_signal, 0); LD_DIAGRAM_GET_CLASS (self)->selection_changed_signal, 0);
} }
}
/** /**
* ld_diagram_load_from_file: * ld_diagram_load_from_file: