[goffice] fixed chart duplication.



commit 48942a1ee68d5c5adc9a9e7266c730cc75d072f9
Author: Jean Brefort <jean brefort normalesup org>
Date:   Thu Nov 26 12:14:10 2009 +0100

    fixed chart duplication.

 ChangeLog                  |    6 +++---
 goffice/graph/gog-object.c |    7 ++++++-
 2 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a829823..f7223c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,8 @@
 2009-11-26  Jean Brefort  <jean brefort normalesup org>
 
-	reviewed by: <delete if not using a buddy>
-
-	* goffice/graph/gog-object.c (gog_object_add_by_role):
+	* goffice/graph/gog-object.c (gog_object_dup): duplicate chart axis set
+	(needed because of the change in gog_object_add_by_role),
+	(gog_object_add_by_role): fail when addition is not allowed.
 
 2009-11-26  Jean Brefort  <jean brefort normalesup org>
 
diff --git a/goffice/graph/gog-object.c b/goffice/graph/gog-object.c
index 7a576fb..67de08f 100644
--- a/goffice/graph/gog-object.c
+++ b/goffice/graph/gog-object.c
@@ -893,6 +893,8 @@ gog_object_dup (GogObject const *src, GogObject *new_parent, GogDataDuplicator d
 		else
 			dataset_dup (GOG_DATASET (src), GOG_DATASET (dst));
 	}
+	if (GOG_IS_CHART (src))
+		GOG_CHART (dst)->axis_set = GOG_CHART (src)->axis_set;
 
 	for (ptr = src->children; ptr != NULL ; ptr = ptr->next)
 		/* children added directly to new parent, no need to use the
@@ -1525,8 +1527,11 @@ gog_object_add_by_role (GogObject *parent, GogObjectRole const *role, GogObject
 	g_return_val_if_fail (is_a != 0, NULL);
 
 	/* do not perform a not allowed addition */
-	if (role->can_add != NULL && !(role->can_add) (parent))
+	if (role->can_add != NULL && !(role->can_add) (parent)) {
+		if (child)
+			g_object_unref (child);
 		return NULL;
+	}
 
 	if (child == NULL) {
 		child = (role->allocate)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]