[rkward-cvs] rkward/rkward/core rcontainerobject.cpp,1.22,1.23 rcontainerobject.h,1.18,1.19 rkvariable.cpp,1.25,1.26

Thomas Friedrichsmeier tfry at users.sourceforge.net
Thu Apr 28 21:23:13 UTC 2005


Update of /cvsroot/rkward/rkward/rkward/core
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28181

Modified Files:
	rcontainerobject.cpp rcontainerobject.h rkvariable.cpp 
Log Message:
Fixed type-mismatch handling (I hope). Definitely less crashy.

Index: rkvariable.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/core/rkvariable.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** rkvariable.cpp	15 Apr 2005 17:24:56 -0000	1.25
--- rkvariable.cpp	28 Apr 2005 21:23:11 -0000	1.26
***************
*** 26,31 ****
  #include "rkmodificationtracker.h"
  
! #define UPDATE_DIM_COMMAND 1
! #define UPDATE_CLASS_COMMAND 2
  #define GET_STORAGE_MODE_COMMAND 10
  #define GET_DATA_COMMAND 11
--- 26,32 ----
  #include "rkmodificationtracker.h"
  
! #define CLASSIFY_COMMAND 1
! #define UPDATE_DIM_COMMAND 2
! #define UPDATE_CLASS_COMMAND 3
  #define GET_STORAGE_MODE_COMMAND 10
  #define GET_DATA_COMMAND 11
***************
*** 107,111 ****
  	getMetaData (RKGlobals::rObjectList()->getUpdateCommandChain ());
  
! 	RCommand *command = new RCommand ("length (" + getFullName () + ")", RCommand::App | RCommand::Sync | RCommand::GetIntVector, "", this, UPDATE_DIM_COMMAND);
  	RKGlobals::rInterface ()->issueCommand (command, RKGlobals::rObjectList()->getUpdateCommandChain ());
  }
--- 108,113 ----
  	getMetaData (RKGlobals::rObjectList()->getUpdateCommandChain ());
  
! // TODO: move classification / type mismatch-checking to RObject
! 	RCommand *command = new RCommand (".rk.classify (" + getFullName () + ")", RCommand::App | RCommand::Sync | RCommand::GetIntVector, "", this, CLASSIFY_COMMAND);
  	RKGlobals::rInterface ()->issueCommand (command, RKGlobals::rObjectList()->getUpdateCommandChain ());
  }
***************
*** 117,121 ****
  	RObject::rCommandDone (command);
  	
! 	if (command->getFlags () == UPDATE_DIM_COMMAND) {
  		if (command->intVectorLength () == 1) {
  			length = command->getIntVector ()[0];
--- 119,151 ----
  	RObject::rCommandDone (command);
  	
! 	if (command->getFlags () == CLASSIFY_COMMAND) {
! 		// WARNING: This code is (mostly) duplicated in RContainerObject!
! 		if (!command->intVectorLength ()) {
! 			RK_ASSERT (false);
! 			return;
! 		}
! 
! 		int new_type = command->getIntVector ()[0];
! 
! 		// check whether this  is still a container object
! 		if ((RObject::type) && (new_type != RObject::type)) {
! 			if ((new_type & RObject::Container)) {
! 				RK_DO (qDebug ("type-mismatch: name: %s, old_type: %d, new_type: %d", RObject::name.latin1 (), type, new_type), OBJECTS, DL_INFO);
! 				RObject::parent->typeMismatch (this, RObject::name);
! 				return;	// will be deleted!
! 			}
! 		}
! 		if (new_type != RObject::type) {
! 			properties_changed = true;
! 			RObject::type = new_type;
! 		}
! 
! 		// classifiy command was successful. now get further information.
! 		RCommand *command = new RCommand ("length (" + getFullName () + ")", RCommand::App | RCommand::Sync | RCommand::GetIntVector, "", this, UPDATE_DIM_COMMAND);
! 		RKGlobals::rInterface ()->issueCommand (command, RKGlobals::rObjectList()->getUpdateCommandChain ());
! 		
! 		if (properties_changed) RKGlobals::tracker ()->objectMetaChanged (this);
! 
! 	} else if (command->getFlags () == UPDATE_DIM_COMMAND) {
  		if (command->intVectorLength () == 1) {
  			length = command->getIntVector ()[0];

Index: rcontainerobject.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/core/rcontainerobject.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** rcontainerobject.cpp	15 Sep 2004 15:03:31 -0000	1.22
--- rcontainerobject.cpp	28 Apr 2005 21:23:10 -0000	1.23
***************
*** 63,66 ****
--- 63,67 ----
  	bool properties_changed = false;
  	if (command->getFlags () == CLASSIFY_COMMAND) {
+ 		// WARNING: This code is (mostly) duplicated in RContainerObject!
  		if (!command->intVectorLength ()) {
  			RK_ASSERT (false);
***************
*** 143,148 ****
  void RContainerObject::typeMismatch (RObject *child, QString childname) {
  	RK_TRACE (OBJECTS);
! 	delete child;
! 	childmap.remove (childname);
  	
  	RKGlobals::tracker ()->removeObject (child, 0, true);
--- 144,151 ----
  void RContainerObject::typeMismatch (RObject *child, QString childname) {
  	RK_TRACE (OBJECTS);
! 	/* I no longer know, why I added the uncommented lines below. From what I can tell today, tracker->removeObject () will call removeChild ()
! 	and the object will be deleted there. Will need to valgrind sonner or later to find out, if those lines did serve a purpose, after all. */
! 	/* delete child;
! 	childmap.remove (childname); */
  	
  	RKGlobals::tracker ()->removeObject (child, 0, true);

Index: rcontainerobject.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/core/rcontainerobject.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** rcontainerobject.h	15 Sep 2004 15:03:31 -0000	1.18
--- rcontainerobject.h	28 Apr 2005 21:23:11 -0000	1.19
***************
*** 66,69 ****
--- 66,70 ----
  private:
  	friend class RObject;
+ 	friend class RKVariable;
  	void typeMismatch (RObject *child, QString childname);
  protected:





More information about the rkward-tracker mailing list