[goffice] check role->can_add before adding a new GogObject



commit 1d99faaeae707b456f6d8ec4ff7191a7fb62aa2d
Author: Jean Brefort <jean brefort normalesup org>
Date:   Thu Nov 26 11:52:29 2009 +0100

    check role->can_add before adding a new GogObject

 ChangeLog                  |    6 ++++++
 goffice/graph/gog-object.c |    4 ++++
 2 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 24beae7..a829823 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 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):
+
+2009-11-26  Jean Brefort  <jean brefort normalesup org>
+
 	* plugins/plot_distrib/gog-probability-plot.c
 	(gog_probability_plot_populate_editor) don't unref the new widget [#603015],
 	(gog_probability_plot_update): check if there is a series before using it.
diff --git a/goffice/graph/gog-object.c b/goffice/graph/gog-object.c
index 2d7f3c1..7a576fb 100644
--- a/goffice/graph/gog-object.c
+++ b/goffice/graph/gog-object.c
@@ -1524,6 +1524,10 @@ 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))
+		return NULL;
+
 	if (child == NULL) {
 		child = (role->allocate)
 			? (role->allocate) (parent)



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