[nautilus-actions] Only set defaults on non-yet allocated data



commit d624a0a4cf090286a968c4dc0245d6431294826a
Author: Pierre Wieser <pwieser trychlos org>
Date:   Sun Mar 28 21:51:28 2010 +0200

    Only set defaults on non-yet allocated data
    
    This prevents a FALSE boolean to be wrongly set to a TRUE default value.

 ChangeLog                    |    5 +++++
 src/core/na-factory-object.c |   17 +++++++++--------
 2 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f9f848f..24e8670 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-03-28 Pierre Wieser <pwieser trychlos org>
+
+	* src/core/na-factory-object.c (set_defaults_iter):
+	Only set a default value when the box has not been yet allocated.
+
 2009-03-26 Pierre Wieser <pwieser trychlos org>
 
 	Releasing 2.30.0.
diff --git a/src/core/na-factory-object.c b/src/core/na-factory-object.c
index 906acde..2c896fd 100644
--- a/src/core/na-factory-object.c
+++ b/src/core/na-factory-object.c
@@ -284,6 +284,12 @@ na_factory_object_set_defaults( NAIFactoryObject *object )
 	}
 }
 
+/*
+ * because this function is called very early in the NAIFactoryObject life,
+ * we assume here that if a NADataBoxed has been allocated, then this is
+ * most probably because it is set. Thus a 'null' value is not considered
+ * as an 'unset' value.
+ */
 static gboolean
 set_defaults_iter( NADataDef *def, NafoDefaultIter *data )
 {
@@ -292,14 +298,9 @@ set_defaults_iter( NADataDef *def, NafoDefaultIter *data )
 
 	is_null = TRUE;
 	boxed = na_ifactory_object_get_data_boxed( data->object, def->name );
-	if( boxed ){
-		is_null = ( na_data_boxed_get_as_void( boxed ) == NULL );
-	}
-	if( is_null ){
-		if( !boxed ){
-			boxed = na_data_boxed_new( def );
-			attach_boxed_to_object( data->object, boxed );
-		}
+	if( !boxed ){
+		boxed = na_data_boxed_new( def );
+		attach_boxed_to_object( data->object, boxed );
 		na_data_boxed_set_from_string( boxed, def->default_value );
 	}
 



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