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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Thu Oct 5 18:47:49 UTC 2006


Revision: 819
          http://svn.sourceforge.net/rkward/?rev=819&view=rev
Author:   tfry
Date:     2006-10-05 11:47:37 -0700 (Thu, 05 Oct 2006)

Log Message:
-----------
Bugfixes, debug code, and API documentation

Modified Paths:
--------------
    trunk/rkward/rkward/agents/rkloadagent.cpp
    trunk/rkward/rkward/agents/rkloadagent.h
    trunk/rkward/rkward/core/robject.cpp
    trunk/rkward/rkward/rbackend/rinterface.cpp
    trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R
    trunk/rkward/rkward/rbackend/rthread.cpp
    trunk/rkward/rkward/rbackend/rthread.h
    trunk/rkward/rkward/windows/rkworkplace.cpp

Modified: trunk/rkward/rkward/agents/rkloadagent.cpp
===================================================================
--- trunk/rkward/rkward/agents/rkloadagent.cpp	2006-10-05 17:36:09 UTC (rev 818)
+++ trunk/rkward/rkward/agents/rkloadagent.cpp	2006-10-05 18:47:37 UTC (rev 819)
@@ -43,12 +43,10 @@
 	KIO::NetAccess::download (url, tmpfile, RKwardApp::getApp ());
 #endif
 
-	update_was_delete = false;
 	RCommand *command;
 	
 	if (!merge) {
 		RKwardApp::getApp ()->slotCloseAllEditors ();
-		update_was_delete = true;
 		command = new RCommand ("remove (list=ls (all.names=TRUE))", RCommand::App | RCommand::ObjectListUpdate);
 		RKGlobals::rInterface ()->issueCommand (command);
 	}
@@ -59,6 +57,9 @@
 	connect (RObjectList::getObjectList (), SIGNAL (updateComplete ()), this, SLOT (listUpdateComplete ()));
 	
 	RObjectList::getObjectList ()->setWorkspaceURL (url);
+
+	RKWorkplace::mainWorkplace ()->restoreWorkplace ();
+	RKWorkplace::mainWorkplace ()->clearWorkplaceDescription ();
 }
 
 RKLoadAgent::~RKLoadAgent () {
@@ -81,13 +82,6 @@
 
 void RKLoadAgent::listUpdateComplete () {
 	RK_TRACE (APP);
-	if (update_was_delete) {
-		update_was_delete = false;
-		RObjectList::getObjectList ()->updateFromR ();
-		return;
-	}
-	RKWorkplace::mainWorkplace ()->restoreWorkplace ();
-	RKWorkplace::mainWorkplace ()->clearWorkplaceDescription ();
 
 	delete this;
 }

Modified: trunk/rkward/rkward/agents/rkloadagent.h
===================================================================
--- trunk/rkward/rkward/agents/rkloadagent.h	2006-10-05 17:36:09 UTC (rev 818)
+++ trunk/rkward/rkward/agents/rkloadagent.h	2006-10-05 18:47:37 UTC (rev 819)
@@ -40,7 +40,6 @@
 private:
 /// needed if file to be loaded is remote
 	QString tmpfile;
-	bool update_was_delete;
 };
 
 #endif

Modified: trunk/rkward/rkward/core/robject.cpp
===================================================================
--- trunk/rkward/rkward/core/robject.cpp	2006-10-05 17:36:09 UTC (rev 818)
+++ trunk/rkward/rkward/core/robject.cpp	2006-10-05 18:47:37 UTC (rev 819)
@@ -198,6 +198,12 @@
 	RK_TRACE (OBJECTS);
 
 	if (command->getFlags () == ROBJECT_UDPATE_STRUCTURE_COMMAND) {
+		if (command->failed ()) {
+			RK_DO (qDebug ("command failed while trying to update object '%s'. No longer present?", getShortName ().latin1 ()), OBJECTS, DL_INFO);
+			// this may happen, if the object has been removed in the workspace in between
+			RKGlobals::tracker ()->removeObject (this, 0, true);
+			return;
+		}
 		if (parent) parent->updateChildStructure (this, command);		// this may result in a delete, so nothing after this!
 		else updateStructure (command);		// if we have no parent, likely we're the RObjectList 
 		return;

Modified: trunk/rkward/rkward/rbackend/rinterface.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rinterface.cpp	2006-10-05 17:36:09 UTC (rev 818)
+++ trunk/rkward/rkward/rbackend/rinterface.cpp	2006-10-05 18:47:37 UTC (rev 819)
@@ -176,6 +176,7 @@
 			RObject *obj = RObjectList::getGlobalEnv ()->findObject (*it);
 			if (obj) {
 				// TODO: maybe this should be put inside a chain
+				RK_DO (qDebug ("update triggered for %s", (*it).latin1 ()), RBACKEND, DL_DEBUG);
 				obj->updateFromR ();
 			} else {
 				RK_DO (qDebug ("lookup failed for changed symbol %s", (*it).latin1 ()), RBACKEND, DL_WARNING);

Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R	2006-10-05 17:36:09 UTC (rev 818)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R	2006-10-05 18:47:37 UTC (rev 819)
@@ -236,7 +236,7 @@
 	oldlist <- ls (.rk.watched.symbols, all.names=TRUE)
 	for (old in oldlist) {		# unwatch no longer present items
 		if (!(old %in% newlist)) {
-			rm (old, envir=.rk.watched.symbols);
+			rm (list=old, envir=.rk.watched.symbols);
 		}
 	}
 

Modified: trunk/rkward/rkward/rbackend/rthread.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rthread.cpp	2006-10-05 17:36:09 UTC (rev 818)
+++ trunk/rkward/rkward/rbackend/rthread.cpp	2006-10-05 18:47:37 UTC (rev 819)
@@ -165,7 +165,8 @@
 			command->datatype = RData::IntVector;
 			command->data = getCommandAsIntVector (ccommand, &(command->length), &error);
 		} else if (ctype & RCommand::GetStructuredData) {
-			command->setData (getCommandAsRData (ccommand, &error));
+			RData *data = getCommandAsRData (ccommand, &error);
+			if (data) command->setData (data);
 		} else {
 			runCommandInternal (ccommand, &error, ctype & RCommand::User);
 		}
@@ -469,6 +470,7 @@
 		QString *strings;
 	
 	// TODO: avoid parsing this over and over again
+		RK_DO (qDebug ("checkObjectUpdatesNeeded: getting search list"), RBACKEND, DL_TRACE);
 		strings = getCommandAsStringVector ("search ()\n", &count, &error);
 		if (count != toplevel_env_count) {
 			search_update_needed = true;
@@ -485,6 +487,7 @@
 		toplevel_env_count = count;
 	
 	// TODO: avoid parsing this over and over again
+		RK_DO (qDebug ("checkObjectUpdatesNeeded: getting globalenv symbols"), RBACKEND, DL_TRACE);
 		strings = getCommandAsStringVector ("ls (globalenv (), all.names=TRUE)\n", &count, &error);
 		if (count != global_env_toplevel_count) {
 			globalenv_update_needed = true;
@@ -517,6 +520,7 @@
 	}
 
 	if (search_update_needed || globalenv_update_needed) {
+		RK_DO (qDebug ("checkObjectUpdatesNeeded: updating watches"), RBACKEND, DL_TRACE);
 		runCommandInternal (".rk.watch.globalenv ()\n", &error);
 	} else {
 		if (!changed_symbol_names.isEmpty ()) {

Modified: trunk/rkward/rkward/rbackend/rthread.h
===================================================================
--- trunk/rkward/rkward/rbackend/rthread.h	2006-10-05 17:36:09 UTC (rev 818)
+++ trunk/rkward/rkward/rbackend/rthread.h	2006-10-05 18:47:37 UTC (rev 819)
@@ -73,11 +73,10 @@
 */
 class RThread : public QThread, public REmbedInternal {
 public:
-/** constructor. You need to specify a pointer to the RInterface, so the thread knows where to post its events. Only one RThread should ever be
-created, and that happens in RInterface::RInterface (). */
+/** constructor. Only one RThread should ever be created, and that happens in RInterface::RInterface (). */
 	RThread ();
 /** destructor */
-	~RThread();
+	~RThread ();
 
 /** @see lock (), @see unlock ()*/
 	enum LockType {
@@ -161,6 +160,7 @@
 /** interrupt processing of the current command. This is much like the user pressing Ctrl+C in a terminal with R. This is probably the only non-portable function in RThread, but I can't see a good way around placing it here, or to make it portable. */
 	void interruptProcessing (bool interrupt);
 
+/** On pthread systems this is the pthread_id of the backend thread. It is needed to send SIGINT to the R backend */
 	Qt::HANDLE thread_id;
 protected:
 /** the main loop. See \ref RThread for a more detailed description */
@@ -172,13 +172,20 @@
 	int locked;
 /** thread is killed. Should exit as soon as possible. @see kill */
 	bool killed;
+/** The internal storage for pauseOutput () */
 	bool output_paused;
 
+/** A copy of the names of the toplevel environments (as returned by "search ()"). */
 	QString *toplevel_env_names;
+/** number of toplevel environments */
 	unsigned int toplevel_env_count;
+/** A copy of the names of the toplevel symbols in the .GlobalEnv. */
 	QString *global_env_toplevel_names;
+/** number of symbols in .GlobalEnv */
 	unsigned int global_env_toplevel_count;
+/** A list of symbols that have been assigned new values during the current command */
 	QStringList changed_symbol_names;
+/** check wether the object list / global environemnt / individual symbols have changed, and updates them, if needed */
 	void checkObjectUpdatesNeeded (bool check_list);
 };
 

Modified: trunk/rkward/rkward/windows/rkworkplace.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkworkplace.cpp	2006-10-05 17:36:09 UTC (rev 818)
+++ trunk/rkward/rkward/windows/rkworkplace.cpp	2006-10-05 18:47:37 UTC (rev 819)
@@ -286,7 +286,7 @@
 void RKWorkplace::clearWorkplaceDescription (RCommandChain *chain) {
 	RK_TRACE (APP);
 
-	RKGlobals::rInterface ()->issueCommand ("remove (.rk.workplace.save)", RCommand::App | RCommand::Sync, QString::null, 0, 0, chain); 
+	RKGlobals::rInterface ()->issueCommand ("remove (.rk.workplace.save)", RCommand::App | RCommand::Sync | RCommand::ObjectListUpdate, QString::null, 0, 0, chain); 
 }
 
 void RKWorkplace::rCommandDone (RCommand *command) {


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