[education/rkward] rkward/rbackend: Also monitor changes in loaded namespaces, actively
Thomas Friedrichsmeier
null at kde.org
Wed Oct 5 16:33:03 BST 2022
Git commit 8ac5a9e4808ea671bbd8bebce8fc200c162fee8d by Thomas Friedrichsmeier.
Committed on 03/10/2022 at 20:03.
Pushed by tfry into branch 'master'.
Also monitor changes in loaded namespaces, actively
M +7 -10 rkward/rbackend/rkrbackend.cpp
M +3 -1 rkward/rbackend/rkrbackend.h
https://invent.kde.org/education/rkward/commit/8ac5a9e4808ea671bbd8bebce8fc200c162fee8d
diff --git a/rkward/rbackend/rkrbackend.cpp b/rkward/rbackend/rkrbackend.cpp
index a481fb50..77ebb401 100644
--- a/rkward/rbackend/rkrbackend.cpp
+++ b/rkward/rbackend/rkrbackend.cpp
@@ -1753,22 +1753,19 @@ void RKRBackend::checkObjectUpdatesNeeded (bool check_list) {
RK_TRACE (RBACKEND);
if (killed) return;
- bool search_update_needed = false;
-
if (check_list) {
// TODO: avoid parsing this over and over again
RK_DEBUG (RBACKEND, DL_TRACE, "checkObjectUpdatesNeeded: getting search list");
- RCommandProxy *dummy = runDirectCommand ("search ()\n", RCommand::GetStringVector);
- if (dummy->stringVector () != toplevel_env_names) search_update_needed = true;
- if (search_update_needed) toplevel_env_names = dummy->stringVector ();
+ RCommandProxy *dummy = runDirectCommand ("list(search(), loadedNamespaces())\n", RCommand::GetStructuredData);
+ QStringList n_toplevel_env_names = dummy->structureVector().value(0)->stringVector();
+ QStringList n_loaded_namespaces = dummy->structureVector().value(1)->stringVector();
delete dummy;
-
- if (search_update_needed) { // this includes an update of the globalenv, even if not needed
- dummy = runDirectCommand ("loadedNamespaces ()\n", RCommand::GetStringVector);
+ if (n_toplevel_env_names != toplevel_env_names || n_loaded_namespaces != loaded_namespaces) { // this includes an update of the globalenv, even if not needed
+ toplevel_env_names = n_toplevel_env_names;
+ loaded_namespaces = n_loaded_namespaces;
QVariantList args;
args.append(QVariant(toplevel_env_names));
- args.append(QVariant(dummy->stringVector()));
- delete dummy;
+ args.append(QVariant(loaded_namespaces));
handleRequestWithSubcommands("syncenvs", args);
}
}
diff --git a/rkward/rbackend/rkrbackend.h b/rkward/rbackend/rkrbackend.h
index 7845fd91..e08db5d3 100644
--- a/rkward/rbackend/rkrbackend.h
+++ b/rkward/rbackend/rkrbackend.h
@@ -215,8 +215,10 @@ private:
void connectCallbacks ();
QString output_file;
-/** A copy of the names of the toplevel environments (as returned by "search ()"). */
+/** A copy of the names of the toplevel environments (as returned by "search()"). */
QStringList toplevel_env_names;
+/** A copy of the names of "loadedNamespaces()"). */
+ QStringList loaded_namespaces;
/** check whether the object list / global environment / individual symbols have changed, and updates them, if needed */
void checkObjectUpdatesNeeded (bool check_list);
friend void doPendingPriorityCommands ();
More information about the rkward-tracker
mailing list