[education/rkward] /: Show warning, if users keep more than 10000 toplevel objects in globalenv.

Thomas Friedrichsmeier null at kde.org
Fri Oct 7 21:14:45 BST 2022


Git commit a1a9500c5f92383739fd4651c690a76d3fa9e99e by Thomas Friedrichsmeier.
Committed on 07/10/2022 at 20:14.
Pushed by tfry into branch 'master'.

Show warning, if users keep more than 10000 toplevel objects in globalenv.

M  +0    -2    ChangeLog
M  +9    -0    rkward/core/renvironmentobject.cpp

https://invent.kde.org/education/rkward/commit/a1a9500c5f92383739fd4651c690a76d3fa9e99e

diff --git a/ChangeLog b/ChangeLog
index ffb67962..417d9e08 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -26,8 +26,6 @@
 			- New KHamburgerMenu to restart the R backend, interrupt all commands and configure the R backend
 - Added: Crosstabs N to N: Simplify labels, add option to control table layout
 - Added: Change mechanism for detection of object changes
-		- TODO:
-			- warn, if users keep more than ~ 20.000 toplevel symbols in globalenv()?
 
 --- Version 0.7.4 - May-30-2022
 - Support "step into" and "finish current" modes in the R debugger window
diff --git a/rkward/core/renvironmentobject.cpp b/rkward/core/renvironmentobject.cpp
index d4078320..a63dbe33 100644
--- a/rkward/core/renvironmentobject.cpp
+++ b/rkward/core/renvironmentobject.cpp
@@ -8,11 +8,13 @@ SPDX-License-Identifier: GPL-2.0-or-later
 #include "renvironmentobject.h"
 
 #include <KLocalizedString>
+#include <KMessageBox>
 
 #include "robjectlist.h"
 #include "rkpseudoobjects.h"
 #include "../rbackend/rkrinterface.h"
 #include "rkmodificationtracker.h"
+#include "../rkward.h"
 
 #include "../debug.h"
 
@@ -105,6 +107,13 @@ void REnvironmentObject::updateFromR(RCommandChain *chain, const QStringList &ad
 			child->updateFromR(chain);
 		}
 	}
+	if (this == RObjectList::getGlobalEnv() && numChildren() >= 10000) {
+		static bool excess_object_warned = false; // show this at most once per session
+		if (!excess_object_warned) {
+			KMessageBox::information(RKWardMainWindow::getMain(), i18n("Your workspace contains more than 10.000 top level objects. RKWard is not optimized for this situation, and you may experience lag between R commands. Should this situation constitute a regular use case for your work, please let us know at rkward-devel at kde.org, so we can consider possible solutions."), i18n("Many objects in workspace"), "excess objects");
+			excess_object_warned = true;
+		}
+	}
 }
 
 bool REnvironmentObject::updateStructure (RData *new_data) {


More information about the rkward-tracker mailing list