[rkward-cvs] SF.net SVN: rkward:[2466] trunk/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Tue May 12 08:25:40 UTC 2009
Revision: 2466
http://rkward.svn.sourceforge.net/rkward/?rev=2466&view=rev
Author: tfry
Date: 2009-05-12 08:25:39 +0000 (Tue, 12 May 2009)
Log Message:
-----------
Don\'t call .rk.get.structure() on the entire .globalenv all of the time
Modified Paths:
--------------
trunk/rkward/ChangeLog
trunk/rkward/TODO
trunk/rkward/rkward/core/renvironmentobject.cpp
trunk/rkward/rkward/core/renvironmentobject.h
trunk/rkward/rkward/core/rkmodificationtracker.cpp
trunk/rkward/rkward/core/robjectlist.cpp
trunk/rkward/rkward/core/robjectlist.h
trunk/rkward/rkward/rbackend/rinterface.cpp
trunk/rkward/rkward/rbackend/rthread.cpp
Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog 2009-05-11 17:29:54 UTC (rev 2465)
+++ trunk/rkward/ChangeLog 2009-05-12 08:25:39 UTC (rev 2466)
@@ -1,4 +1,5 @@
-- Fixed: Screen device in rkward was not seen as interactive by R TODO: backport
+- Fixed: All objects in .Globalenv would be revisited if a single object was added / removed TODO: backport? (r2466)
+- Fixed: Screen device in rkward was not seen as interactive by R TODO: backport (r2462)
--- Version 0.5.0d - May-10-2009
- Fixed: Container of detached windows would sometimes remain after reattaching
Modified: trunk/rkward/TODO
===================================================================
--- trunk/rkward/TODO 2009-05-11 17:29:54 UTC (rev 2465)
+++ trunk/rkward/TODO 2009-05-12 08:25:39 UTC (rev 2466)
@@ -32,6 +32,7 @@
Compilation / technical
- Incorporate FreeBSD patches http://www.freshports.org/math/rkward/files.php?message_id=200609172111.k8HLBiob081349@repoman.freebsd.org
- cleanup DISABLE_RKWINDOWCATCHER (either get rid of it, or do it right)
+ - eventually the whole RData-structure should be made to use QList-types
UI-stuff
- find/create a set of menu icons (https://sourceforge.net/mailarchive/message.php?msg_id=37891606)
Modified: trunk/rkward/rkward/core/renvironmentobject.cpp
===================================================================
--- trunk/rkward/rkward/core/renvironmentobject.cpp 2009-05-11 17:29:54 UTC (rev 2465)
+++ trunk/rkward/rkward/core/renvironmentobject.cpp 2009-05-12 08:25:39 UTC (rev 2466)
@@ -2,7 +2,7 @@
renvironmentobject - description
-------------------
begin : Wed Sep 27 2006
- copyright : (C) 2006 by Thomas Friedrichsmeier
+ copyright : (C) 2006, 2009 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -23,6 +23,7 @@
#include "robjectlist.h"
#include "../rbackend/rinterface.h"
#include "../settings/rksettingsmoduleobjectbrowser.h"
+#include "rkmodificationtracker.h"
#include "../rkglobals.h"
#include "../debug.h"
@@ -101,6 +102,31 @@
RKGlobals::rInterface ()->issueCommand (command, chain);
}
+void REnvironmentObject::updateFromR (RCommandChain *chain, const QStringList ¤t_symbols) {
+ RK_TRACE (OBJECTS);
+
+ // only needed for the assert at the end
+ int debug_baseline = 0;
+
+ // which children are missing?
+ for (int i = childmap.size () - 1; i >= 0; --i) {
+ RObject *object = childmap[i];
+ if (!current_symbols.contains (object->getShortName ())) {
+ if (!(RKGlobals::tracker ()->removeObject (object, 0, true))) debug_baseline++;
+ }
+ }
+
+ // which ones are new in the list?
+ for (int i = current_symbols.count () - 1; i >= 0; --i) {
+ if (!findChildByName (current_symbols[i])) {
+ RObject *child = createPendingChild (current_symbols[i], i, false, false);
+ child->updateFromR (chain);
+ }
+ }
+
+ RK_ASSERT ((debug_baseline + current_symbols.count ()) == childmap.size ());
+}
+
bool REnvironmentObject::updateStructure (RData *new_data) {
RK_TRACE (OBJECTS);
RK_ASSERT (new_data->getDataType () == RData::StructureVector);
Modified: trunk/rkward/rkward/core/renvironmentobject.h
===================================================================
--- trunk/rkward/rkward/core/renvironmentobject.h 2009-05-11 17:29:54 UTC (rev 2465)
+++ trunk/rkward/rkward/core/renvironmentobject.h 2009-05-12 08:25:39 UTC (rev 2466)
@@ -2,7 +2,7 @@
renvironmentobject - description
-------------------
begin : Wed Sep 27 2006
- copyright : (C) 2006 by Thomas Friedrichsmeier
+ copyright : (C) 2006, 2009 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -33,6 +33,8 @@
~REnvironmentObject ();
void updateFromR (RCommandChain *chain);
+/** like updateFromR, but only update new / removed symbols from R. Theoretically this could be defined in RContainerObject, but the only use case is for environments. */
+ void updateFromR (RCommandChain *chain, const QStringList ¤t_symbols);
QString getFullName () const;
QString makeChildName (const QString &short_child_name, bool misplaced=false) const;
Modified: trunk/rkward/rkward/core/rkmodificationtracker.cpp
===================================================================
--- trunk/rkward/rkward/core/rkmodificationtracker.cpp 2009-05-11 17:29:54 UTC (rev 2465)
+++ trunk/rkward/rkward/core/rkmodificationtracker.cpp 2009-05-12 08:25:39 UTC (rev 2466)
@@ -2,7 +2,7 @@
rkmodificationtracker - description
-------------------
begin : Tue Aug 31 2004
- copyright : (C) 2004, 2007 by Thomas Friedrichsmeier
+ copyright : (C) 2004, 2007, 2009 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -64,9 +64,7 @@
if (removed_in_workspace) {
if (ed) {
if (KMessageBox::questionYesNo (0, i18n ("The object '%1' was removed from workspace or changed to a different type of object, but is currently opened for editing. Do you want to restore it?", object->getFullName ()), i18n ("Restore object?")) == KMessageBox::Yes) {
-qDebug ("a");
ed->restoreObject (object);
-qDebug ("b");
return false;
}
}
Modified: trunk/rkward/rkward/core/robjectlist.cpp
===================================================================
--- trunk/rkward/rkward/core/robjectlist.cpp 2009-05-11 17:29:54 UTC (rev 2465)
+++ trunk/rkward/rkward/core/robjectlist.cpp 2009-05-12 08:25:39 UTC (rev 2466)
@@ -2,7 +2,7 @@
robjectlist - description
-------------------
begin : Wed Aug 18 2004
- copyright : (C) 2004, 2006, 2007 by Thomas Friedrichsmeier
+ copyright : (C) 2004, 2006, 2007, 2009 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -59,6 +59,7 @@
void RObjectList::updateFromR (RCommandChain *chain) {
RK_TRACE (OBJECTS);
+
if (update_chain) {
// gee, looks like another update is still on the way. lets schedule one for later:
update_timer->start (UPDATE_DELAY_INTERVAL);
@@ -73,6 +74,25 @@
RKGlobals::rInterface ()->issueCommand (command, update_chain);
}
+void RObjectList::updateFromR (RCommandChain *chain, const QStringList ¤t_searchpath) {
+ RK_TRACE (OBJECTS);
+
+// TODO: can this happen? when?
+ if (update_chain) {
+ // gee, looks like another update is still on the way. lets schedule one for later:
+ update_timer->start (UPDATE_DELAY_INTERVAL);
+ RK_DO (qDebug ("another object-list update is already running. Rescheduling a further update for later"), OBJECTS, DL_DEBUG);
+ return;
+ }
+
+ emit (updateStarted ());
+ update_chain = RKGlobals::rInterface ()->startChain (chain);
+
+ updateEnvironments (current_searchpath, false);
+
+ RKGlobals::rInterface ()->issueCommand (QString (), RCommand::App | RCommand::Sync | RCommand::EmptyCommand, QString (), this, ROBJECTLIST_UDPATE_COMPLETE_COMMAND, update_chain);
+}
+
void RObjectList::rCommandDone (RCommand *command) {
RK_TRACE (OBJECTS);
@@ -80,9 +100,12 @@
unsigned int num_new_environments = command->getDataLength ();
RK_ASSERT (command->getDataType () == RData::StringVector);
RK_ASSERT (num_new_environments >= 2);
- QString *new_environments = command->getStringVector ();
- updateEnvironments (new_environments, num_new_environments);
+ QStringList new_environments;
+ for (unsigned int i = 0; i < num_new_environments; ++i) {
+ new_environments.append (command->getStringVector ()[i]);
+ }
+ updateEnvironments (new_environments, true);
RKGlobals::rInterface ()->issueCommand (QString (), RCommand::App | RCommand::Sync | RCommand::EmptyCommand, QString (), this, ROBJECTLIST_UDPATE_COMPLETE_COMMAND, update_chain);
} else if (command->getFlags () == ROBJECTLIST_UDPATE_COMPLETE_COMMAND) {
@@ -97,19 +120,19 @@
}
}
-void RObjectList::updateEnvironments (QString *env_names, unsigned int env_count) {
+void RObjectList::updateEnvironments (const QStringList &env_names, bool force_globalenv_update) {
RK_TRACE (OBJECTS);
RObjectMap newchildmap;
// find which items are new, and copy the old ones
- for (unsigned int i = 0; i < env_count; ++i) {
+ for (int i = 0; i < env_names.count (); ++i) {
QString name = env_names[i];
RObject* obj = findChildByName (name);
if (obj) {
// for now, we only update the .GlobalEnv. All others we assume to be static
- if (obj->isType (GlobalEnv)) {
+ if (obj->isType (GlobalEnv) && force_globalenv_update) {
obj->updateFromR (update_chain);
}
} else {
Modified: trunk/rkward/rkward/core/robjectlist.h
===================================================================
--- trunk/rkward/rkward/core/robjectlist.h 2009-05-11 17:29:54 UTC (rev 2465)
+++ trunk/rkward/rkward/core/robjectlist.h 2009-05-12 08:25:39 UTC (rev 2466)
@@ -2,7 +2,7 @@
robjectlist - description
-------------------
begin : Wed Aug 18 2004
- copyright : (C) 2004, 2006, 2007 by Thomas Friedrichsmeier
+ copyright : (C) 2004, 2006, 2007, 2009 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -46,6 +46,8 @@
~RObjectList ();
void updateFromR (RCommandChain *chain);
+ /** like updateFromR, but only adjusts to new / missing environments, but does not update the .GlobalEnv. Designed to be used from the backend, when packages were loaded/unloaded . */
+ void updateFromR (RCommandChain *chain, const QStringList ¤t_searchpath);
QString getFullName () const { return QString (); };
QString makeChildName (const QString &short_child_name, bool) const { return short_child_name; };
@@ -80,7 +82,7 @@
void objectsChanged ();
bool updateStructure (RData *new_data);
void rCommandDone (RCommand *command);
- void updateEnvironments (QString *env_names, unsigned int env_count);
+ void updateEnvironments (const QStringList &env_names, bool force_globalenv_update);
private:
friend class RKLoadAgent;
friend class RKSaveAgent;
Modified: trunk/rkward/rkward/rbackend/rinterface.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rinterface.cpp 2009-05-11 17:29:54 UTC (rev 2465)
+++ trunk/rkward/rkward/rbackend/rinterface.cpp 2009-05-12 08:25:39 UTC (rev 2466)
@@ -326,16 +326,12 @@
RK_DO (qDebug ("lookup failed for changed symbol %s", object_name.toLatin1 ().data()), RBACKEND, DL_WARNING);
}
}
- } else if (call == "syncall") {
- RK_ASSERT (request->call.count () == 1);
-
+ } else if (call == "syncenvs") {
RK_DO (qDebug ("triggering update of object list"), RBACKEND, DL_DEBUG);
- RObjectList::getObjectList ()->updateFromR (request->in_chain);
+ RObjectList::getObjectList ()->updateFromR (request->in_chain, request->call.mid (1));
} else if (call == "syncglobal") {
- RK_ASSERT (request->call.count () == 1);
-
RK_DO (qDebug ("triggering update of globalenv"), RBACKEND, DL_DEBUG);
- RObjectList::getGlobalEnv ()->updateFromR (request->in_chain);
+ RObjectList::getGlobalEnv ()->updateFromR (request->in_chain, request->call.mid (1));
} else if (call == "edit") {
RK_ASSERT (request->call.count () >= 2);
Modified: trunk/rkward/rkward/rbackend/rthread.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rthread.cpp 2009-05-11 17:29:54 UTC (rev 2465)
+++ trunk/rkward/rkward/rbackend/rthread.cpp 2009-05-12 08:25:39 UTC (rev 2466)
@@ -594,12 +594,15 @@
if (search_update_needed) { // this includes an update of the globalenv, even if not needed
MUTEX_UNLOCK;
- QStringList call ("syncall");
+ QStringList call = toplevel_env_names;
+ call.prepend ("syncenvs"); // should be faster than the reverse
handleSubstackCall (call);
MUTEX_LOCK;
- } else if (globalenv_update_needed) {
+ }
+ if (globalenv_update_needed) {
MUTEX_UNLOCK;
- QStringList call ("syncglobal");
+ QStringList call = global_env_toplevel_names;
+ call.prepend ("syncglobal"); // should be faster than the reverse
handleSubstackCall (call);
MUTEX_LOCK;
}
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