[rkward-cvs] SF.net SVN: rkward: [850] trunk/rkward/rkward/core

tfry at users.sourceforge.net tfry at users.sourceforge.net
Wed Oct 11 21:14:56 UTC 2006


Revision: 850
          http://svn.sourceforge.net/rkward/?rev=850&view=rev
Author:   tfry
Date:     2006-10-11 14:14:49 -0700 (Wed, 11 Oct 2006)

Log Message:
-----------
Make RKVariable (edited) behave gracefully (but not yet smart), when data type changes in the backend

Modified Paths:
--------------
    trunk/rkward/rkward/core/rkvariable.cpp
    trunk/rkward/rkward/core/rkvariable.h
    trunk/rkward/rkward/core/robject.h

Modified: trunk/rkward/rkward/core/rkvariable.cpp
===================================================================
--- trunk/rkward/rkward/core/rkvariable.cpp	2006-10-11 20:26:53 UTC (rev 849)
+++ trunk/rkward/rkward/core/rkvariable.cpp	2006-10-11 21:14:49 UTC (rev 850)
@@ -50,8 +50,6 @@
 	RK_TRACE (OBJECTS);
 
 	if (getDataType () == new_type) {
-		// of course this is not harmful in any way, but in order to catch this kind of use, we raise an assert here for now.
-		RK_ASSERT (false);
 		return;
 	}
 
@@ -219,6 +217,21 @@
 	}
 }
 
+bool RKVariable::updateType (RData *new_data) {
+	RK_TRACE (OBJECTS);
+
+	if (myData ()) {
+		int old_type = type;
+		bool ret = RObject::updateType (new_data);
+		int new_type = type;
+		type = old_type;		// needed to read out the old data
+		setVarType (typeToDataType (new_type), false);
+		type = new_type;
+		return ret;
+	}
+	return RObject::updateType (new_data);
+}
+
 // virtual
 void RKVariable::initializeEditData (bool to_empty) {
 	RK_TRACE (OBJECTS);

Modified: trunk/rkward/rkward/core/rkvariable.h
===================================================================
--- trunk/rkward/rkward/core/rkvariable.h	2006-10-11 20:26:53 UTC (rev 849)
+++ trunk/rkward/rkward/core/rkvariable.h	2006-10-11 21:14:49 UTC (rev 850)
@@ -135,6 +135,8 @@
 	static QString *unknown_char;
 
 protected:
+/** reimplemented from RObject to change the internal data storage mode, if the var is being edited */
+	bool updateType (RData *new_data);
 /** Extended from RObject::EditData to actually contain data. */
 	struct RKVarEditData : public EditData {
 		QString *cell_strings;

Modified: trunk/rkward/rkward/core/robject.h
===================================================================
--- trunk/rkward/rkward/core/robject.h	2006-10-11 20:26:53 UTC (rev 849)
+++ trunk/rkward/rkward/core/robject.h	2006-10-11 21:14:49 UTC (rev 850)
@@ -135,7 +135,8 @@
 /** array of child objects. Always 0, reimplemented in RContainerObject */
 	virtual RObject **children () { return 0; };
 
-	RDataType getDataType () { return ((RDataType) ((type & DataTypeMask) >> 14)); };
+	RDataType getDataType () { return (typeToDataType (type)); };
+	static RDataType typeToDataType (int ftype) { return ((RDataType) ((ftype & DataTypeMask) >> 14)); };
 	void setDataType (RDataType new_type) {
 		int n_type = type - (type & DataTypeMask);
 		type = n_type + (new_type << 14);
@@ -213,7 +214,7 @@
 /** update type information from the given data.
 @param new_data The command. Make sure it really is the classification field of an .rk.get.structure-command to update classes *before* calling this function! WARNING: the new_data object may get changed during this call. Call canAccommodateStructure () before calling this function!
 @returns whether this caused any changes */
-	bool updateType (RData *new_data);
+	virtual bool updateType (RData *new_data);
 /** handles updating class names from the given data (common functionality between RContainerObject and RKVariable
 @param new_data The data. Make sure it really is the classes field of an .rk.get.structure-command to update classes *before* calling this function! WARNING: the new_data object may get changed during this call. Call canAccommodateStructure () before calling this function!
 @returns whether this caused any changes */


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list