[dia] Object add/remove signaled only once per diagram change
- From: Hans Breuer <hans src gnome org>
- To: svn-commits-list gnome org
- Subject: [dia] Object add/remove signaled only once per diagram change
- Date: Fri, 12 Jun 2009 13:53:53 -0400 (EDT)
commit 2adebd449b21579f6666a8159206f3bd0f42fc8c
Author: Hans Breuer <hans breuer org>
Date: Fri Jun 12 16:44:33 2009 +0200
Object add/remove signaled only once per diagram change
app/diagram.c | 2 +-
app/undo.c | 20 ++++++++------------
lib/layer.c | 19 +++++++++++++------
3 files changed, 22 insertions(+), 19 deletions(-)
---
diff --git a/app/diagram.c b/app/diagram.c
index c05d064..b60c0e4 100644
--- a/app/diagram.c
+++ b/app/diagram.c
@@ -743,7 +743,7 @@ diagram_selected_break_external(Diagram *dia)
connected_list = g_list_next(connected_list);
}
}
- data_emit (dia->data, dia_object_get_parent_layer(obj), obj, "object_remove");
+
list = g_list_next(list);
}
}
diff --git a/app/undo.c b/app/undo.c
index 88f81cc..9a3d634 100644
--- a/app/undo.c
+++ b/app/undo.c
@@ -658,18 +658,14 @@ delete_objects_revert(struct DeleteObjectsChange *change, Diagram *dia)
g_list_copy(change->original_objects));
object_add_updates_list(change->obj_list, dia);
- list = change->obj_list;
- while (list)
- {
- DiaObject *obj = (DiaObject *) list->data;
- if (obj->parent) /* Restore child references */
- obj->parent->children = g_list_append(obj->parent->children, obj);
-
- /* Emit a signal per object reverted */
- data_emit(layer_get_parent_diagram(change->layer),change->layer,obj,"object_add");
-
- list = g_list_next(list);
- }
+ list = change->obj_list;
+ while (list) {
+ DiaObject *obj = (DiaObject *) list->data;
+ if (obj->parent) /* Restore child references */
+ obj->parent->children = g_list_append(obj->parent->children, obj);
+ /* no need to emit object_add signal, already done by layer_set_object_list */
+ list = g_list_next(list);
+ }
}
static void
diff --git a/lib/layer.c b/lib/layer.c
index d78f2ea..c5dd131 100644
--- a/lib/layer.c
+++ b/lib/layer.c
@@ -255,13 +255,14 @@ layer_remove_objects(Layer *layer, GList *obj_list)
while (obj_list != NULL) {
obj = (DiaObject *) obj_list->data;
+ /* send a signal that we will remove an object from the diagram */
+ data_emit (layer_get_parent_diagram(layer), layer, obj, "object_remove");
+
layer->objects = g_list_remove(layer->objects, obj);
obj_list = g_list_next(obj_list);
dynobj_list_remove_object(obj);
set_parent_layer(obj, NULL);
- /* send a signal that we have removed a object from the diagram */
- data_emit (layer_get_parent_diagram(layer), layer, obj, "object_remove");
}
}
@@ -537,26 +538,32 @@ layer_remove_dynobj(gpointer obj, gpointer userdata)
dynobj_list_remove_object((DiaObject*)obj);
}
-void layer_set_object_list(Layer *layer, GList *list)
+void
+layer_set_object_list(Layer *layer, GList *list)
{
GList *ol;
/* signal removal on all objects */
ol = layer->objects;
while (ol) {
- data_emit (layer_get_parent_diagram(layer), layer, ol->data, "object_remove");
+ if (!g_list_find (list, ol->data)) /* only if it really vanishes */
+ data_emit (layer_get_parent_diagram(layer), layer, ol->data, "object_remove");
ol = g_list_next (ol);
}
+ /* restore old list */
+ ol = layer->objects;
g_list_foreach(layer->objects, set_parent_layer, NULL);
g_list_foreach(layer->objects, layer_remove_dynobj, NULL);
- g_list_free(layer->objects);
+
layer->objects = list;
g_list_foreach(layer->objects, set_parent_layer, layer);
/* signal addition on all objects */
list = layer->objects;
while (list) {
- data_emit (layer_get_parent_diagram(layer), layer, list->data, "object_add");
+ if (!g_list_find (ol, list->data)) /* only if it is new */
+ data_emit (layer_get_parent_diagram(layer), layer, list->data, "object_add");
list = g_list_next (list);
}
+ g_list_free(ol);
}
DiagramData *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]