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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Thu Oct 19 15:05:54 UTC 2006


Revision: 883
          http://svn.sourceforge.net/rkward/?rev=883&view=rev
Author:   tfry
Date:     2006-10-19 08:05:39 -0700 (Thu, 19 Oct 2006)

Log Message:
-----------
Fix to deal correctly with pending objects (object which have been created in the list, but not yet in the backend
previously those would cause trouble if/when an object update does not find them in the backend

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/TODO
    trunk/rkward/rkward/core/rcontainerobject.cpp
    trunk/rkward/rkward/core/robject.cpp
    trunk/rkward/rkward/core/robject.h
    trunk/rkward/rkward/core/robjectlist.h
    trunk/rkward/rkward/dataeditor/rkeditor.h
    trunk/rkward/rkward/dataeditor/rkeditordataframe.cpp
    trunk/rkward/rkward/dataeditor/twintablemember.cpp
    trunk/rkward/rkward/robjectbrowser.cpp

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2006-10-19 14:11:38 UTC (rev 882)
+++ trunk/rkward/ChangeLog	2006-10-19 15:05:39 UTC (rev 883)
@@ -1,3 +1,5 @@
+- added R function rk.edit (x) to open object x for editing in rkward
+- fixed: an empty table created before the object list was updated (esp. at startup) would be thought to have been removed in the workspace
 - object data changed in the console (or by other means) is updated to the editor automatically, if the object is opened for editing
 - fixed: back / forward buttons would sometimes remain after closing a help window
 - fix some focus problems

Modified: trunk/rkward/TODO
===================================================================
--- trunk/rkward/TODO	2006-10-19 14:11:38 UTC (rev 882)
+++ trunk/rkward/TODO	2006-10-19 15:05:39 UTC (rev 883)
@@ -13,6 +13,12 @@
 		- Probably the RKConsole is to blame (run outside console -> no significant increase)
 			- Maybe the kate-part needs to be reset (syntax parse tree) every once in a while?
 	- rnorm () and friends auto-print value only once. R_Visible is 0 on subsequent calls (what in the world is going on, here?)
+	- RKEditorDataFrame:
+		- sometimes the current cell idicator (the box around the current cell) gets lost.
+			- Navigation and editing is still fine
+			- seems to happen more often with larger data frames
+			- more precisely: seems to happen after scrolling
+			- no idea, why this happens
 
 Compilation / technical
 	- Incorporate FreeBSD patches http://www.freshports.org/math/rkward/files.php?message_id=200609172111.k8HLBiob081349@repoman.freebsd.org

Modified: trunk/rkward/rkward/core/rcontainerobject.cpp
===================================================================
--- trunk/rkward/rkward/core/rcontainerobject.cpp	2006-10-19 14:11:38 UTC (rev 882)
+++ trunk/rkward/rkward/core/rcontainerobject.cpp	2006-10-19 15:05:39 UTC (rev 883)
@@ -53,7 +53,7 @@
 	} else {
 		if (just_created) {
 			RK_ASSERT (false);
-			RK_DO (qDebug (child->getFullName ().latin1 ()), OBJECTS, DL_ERROR);
+			RK_DO (qDebug ("%s", child->getFullName ().latin1 ()), OBJECTS, DL_ERROR);
 			delete child;
 			return 0;
 		} else {
@@ -160,7 +160,11 @@
 		QString child_string = it.key ();
 
 		if (new_childmap.find (child_string) == new_childmap.end ()) {
-			removed_list.append (it.data ());
+			if (it.data ()->isPending ()) {
+				new_childmap.insert (child_string, it.data ());
+			} else {
+				removed_list.append (it.data ());
+			}
 		}
 	}
 

Modified: trunk/rkward/rkward/core/robject.cpp
===================================================================
--- trunk/rkward/rkward/core/robject.cpp	2006-10-19 14:11:38 UTC (rev 882)
+++ trunk/rkward/rkward/core/robject.cpp	2006-10-19 15:05:39 UTC (rev 883)
@@ -281,6 +281,7 @@
 
 	if (properties_change) RKGlobals::tracker ()->objectMetaChanged (this);
 	if (data && (data->dirty)) updateDataFromR (0);
+	if (data) data->pending = false;
 
 	return true;
 }
@@ -550,6 +551,7 @@
 		initializeEditDataToEmpty ();
 	}
 	data->editor = editor;
+	data->pending = true;
 }
 
 // virtual
@@ -561,8 +563,16 @@
 	
 	data = new EditData;
 	data->dirty = false;
+	data->pending = false;
 }
 
+bool RObject::isPending () {
+	RK_TRACE (OBJECTS);
+
+	if (!data) return false;
+	return (data->pending);
+}
+
 // virtual
 void RObject::initializeEditDataToEmpty () {
 	RK_TRACE (OBJECTS);

Modified: trunk/rkward/rkward/core/robject.h
===================================================================
--- trunk/rkward/rkward/core/robject.h	2006-10-19 14:11:38 UTC (rev 882)
+++ trunk/rkward/rkward/core/robject.h	2006-10-19 15:05:39 UTC (rev 883)
@@ -236,6 +236,7 @@
 	struct EditData {
 		RKEditor *editor;
 		bool dirty;
+		bool pending;		// maybe move to type instead
 	};
 /** see EditData. 0 if the object is not being edited. */
 	EditData *data;
@@ -246,6 +247,8 @@
 /** see above */
 	virtual void discardEditData ();
 
+	bool isPending ();
+
 	void rCommandDone (RCommand *command);
 };
 

Modified: trunk/rkward/rkward/core/robjectlist.h
===================================================================
--- trunk/rkward/rkward/core/robjectlist.h	2006-10-19 14:11:38 UTC (rev 882)
+++ trunk/rkward/rkward/core/robjectlist.h	2006-10-19 15:05:39 UTC (rev 883)
@@ -57,6 +57,7 @@
 
 	/** reimplemented from RContainerObject to create the child in the .GlobalEnv */
 	RObject *createNewChild (const QString &name, RKEditor *creator=0, bool container=false, bool data_frame=false);
+
 	/** reimplemented from RContainerObject to validize the name in .GlobalEnv */
 	QString validizeName (const QString &child_name);
 

Modified: trunk/rkward/rkward/dataeditor/rkeditor.h
===================================================================
--- trunk/rkward/rkward/dataeditor/rkeditor.h	2006-10-19 14:11:38 UTC (rev 882)
+++ trunk/rkward/rkward/dataeditor/rkeditor.h	2006-10-19 15:05:39 UTC (rev 883)
@@ -72,7 +72,7 @@
 protected:
 friend class RKWorkplace;
 /// opens the given object. Implement in the child-classes
-	virtual void openObject (RObject *object, bool initialize_to_empty=false) = 0;
+	virtual void openObject (RObject *object, bool initialize_to_empty) = 0;
 
 	RObject *object;
 

Modified: trunk/rkward/rkward/dataeditor/rkeditordataframe.cpp
===================================================================
--- trunk/rkward/rkward/dataeditor/rkeditordataframe.cpp	2006-10-19 14:11:38 UTC (rev 882)
+++ trunk/rkward/rkward/dataeditor/rkeditordataframe.cpp	2006-10-19 15:05:39 UTC (rev 883)
@@ -75,10 +75,15 @@
 	RK_TRACE (EDITOR);
 	flushEdit ();
 	RKEditor::object = object;
-	object->setObjectOpened (this, true);
+	if (initialize_to_empty) {
+		object->setCreatedInEditor (this);
+	} else {
+		object->setObjectOpened (this, true);
+	}
 
 	enableEditing (false);
 	open_chain = RKGlobals::rInterface ()->startChain (open_chain);
+
 	if (initialize_to_empty) {
 		for (int i=0; i < numTrueCols (); ++i) {
 			RObject *obj = static_cast<RContainerObject *> (getObject ())->createNewChild (static_cast<RContainerObject *> (getObject ())->validizeName ("var"), this);
@@ -94,6 +99,8 @@
 	}
 
 	// actually, given the object, we already know the child-names. We don't know their order, however, so we better fetch the name-row again.
+	object->markDataDirty ();
+	object->updateFromR (open_chain);
 	RCommand *command = new RCommand ("names (" + object->getFullName () + ")", RCommand::Sync | RCommand::GetStringVector, QString::null, this, GET_NAMES_COMMAND);
 	RKGlobals::rInterface ()->issueCommand (command, open_chain);
 
@@ -110,27 +117,15 @@
 			deleteColumn (0);
 		}
 
-		// this is really just a very preliminary HACK. If stringVectorLength () is 0, this can not be a data.frame any longer.
-		// abort in order to avoid crash.
-		// TODO: actually, we should have a true check for object type each time before opening an object.
-		if (!len) {
-			open_chain = RKGlobals::rInterface ()->closeChain (open_chain);
-			delete this;
-			return;
-		}
+		RK_ASSERT (len);
 
 		// set the names and meta-information
 		for (int col = 0; col < len; ++col) {
 			if (numTrueCols () <= col) {
 				insertNewColumn ();
 			}
-			// TODO: make clean
 			RKVariable *current_child = static_cast<RKVariable *> (static_cast <RContainerObject*> (getObject ())->findChild (command->getStringVector ()[col]));
-			// this is really just a very preliminary HACK. If we find new children now exist, create them now in order to avoid crash..
-			// TODO: actually, we should have a true check for object type/structure each time before opening an object.
-			if (!current_child) {
-				current_child = static_cast<RKVariable *> (static_cast<RContainerObject *> (getObject ())->createNewChild (command->getStringVector ()[col], this));
-			}
+			RK_ASSERT (current_child);
 			if (current_child->isVariable ()) {
 				if (!getColObject (col)) {		// if we initialized the table to empty, the object may already exist in our map
 					setColObject (col, current_child);

Modified: trunk/rkward/rkward/dataeditor/twintablemember.cpp
===================================================================
--- trunk/rkward/rkward/dataeditor/twintablemember.cpp	2006-10-19 14:11:38 UTC (rev 882)
+++ trunk/rkward/rkward/dataeditor/twintablemember.cpp	2006-10-19 15:05:39 UTC (rev 883)
@@ -80,15 +80,15 @@
 			mouse_at = mouseEvent->globalPos ();
 			if (object == horizontalHeader ()) {
 				emit headerRightClick (-1, horizontalHeader ()->sectionAt (contentsX () + mouseEvent->x ()));
-                return (true); // got it
-            }
+				return (true); // got it
+			}
 			if (object == verticalHeader ()) {
 				emit headerRightClick (verticalHeader ()->sectionAt (contentsY () + mouseEvent->y ()), -1);
-                return (true); // got it
-            }
-        }
+				return (true); // got it
+			}
+		}
 		setFocus ();
-    }
+	}
 
     // default processing
     return (QTable::eventFilter (object, event));

Modified: trunk/rkward/rkward/robjectbrowser.cpp
===================================================================
--- trunk/rkward/rkward/robjectbrowser.cpp	2006-10-19 14:11:38 UTC (rev 882)
+++ trunk/rkward/rkward/robjectbrowser.cpp	2006-10-19 15:05:39 UTC (rev 883)
@@ -111,9 +111,7 @@
 	if (ok) {
 		QString valid = RObjectList::getGlobalEnv ()->validizeName (name);
 		if (valid != name) KMessageBox::sorry (this, i18n ("The name you specified was already in use or not valid. Renamed to %1").arg (valid), i18n ("Invalid Name"));
-		RObject *copy = RObjectList::getGlobalEnv ()->createNewChild (valid, 0, true, true);
 		RKGlobals::rInterface ()->issueCommand (RObject::rQuote (valid) + " <- " + object->getFullName (), RCommand::App | RCommand::ObjectListUpdate);
-		copy->updateFromR (0);
 	}
 }
 
@@ -125,9 +123,7 @@
 
 	QString valid = RObjectList::getGlobalEnv ()->validizeName (name);
 	if (valid != name) KMessageBox::sorry (this, i18n ("An object named '%1' already exists in the GlobalEnv. Created the copy as '%2' instead.").arg (name).arg (valid), i18n ("Name already in use"));
-	RObject *copy = RObjectList::getGlobalEnv ()->createNewChild (valid, 0, true, true);
 	RKGlobals::rInterface ()->issueCommand (RObject::rQuote (valid) + " <- " + object->getFullName (), RCommand::App | RCommand::ObjectListUpdate);
-	copy->updateFromR (0);
 }
 
 void RObjectBrowser::popupView () {


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