[education/rkward] /: Fix object list when restarting backend, provide a warning dialog.
Thomas Friedrichsmeier
null at kde.org
Sat Jun 4 20:55:53 BST 2022
Git commit 3b94440f972d08eed3aee27531ff0bd0efd3a614 by Thomas Friedrichsmeier.
Committed on 04/06/2022 at 19:54.
Pushed by tfry into branch 'master'.
Fix object list when restarting backend, provide a warning dialog.
M +1 -6 ChangeLog
M +3 -4 rkward/core/robjectlist.cpp
M +7 -1 rkward/rkward.cpp
https://invent.kde.org/education/rkward/commit/3b94440f972d08eed3aee27531ff0bd0efd3a614
diff --git a/ChangeLog b/ChangeLog
index 1fe4d5d1..d7021378 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,6 @@
- Fix problem handling rkward:// links from dialogs on some sytems
- Allow to select search provider, when searching for a term online
-- Experimental: Add option to restart R backend
- - TODO: fix mem-leaks
- - TODO: fix action label / placemnt / add confirmation dialog, etc.
- - TODO: make sure to close all data editors, object viewers, and plots
- - TODO: offer in backend crash message?
- - TODO: In case R version has changed, check setup?
+- Experimental feature targetted at package developers: Add option to restart R backend
- Fix object name completion for (irregular) names starting with numbers or underscores
- Crosstabs N to N: Simplify labels, add option to control table layout
- Change mechanism for detection of object changes
diff --git a/rkward/core/robjectlist.cpp b/rkward/core/robjectlist.cpp
index 11c16d0c..afdad12b 100644
--- a/rkward/core/robjectlist.cpp
+++ b/rkward/core/robjectlist.cpp
@@ -65,13 +65,12 @@ void RObjectList::init() {
} else {
auto *globalenv = object_list->globalenv; // easier typing
for (int i = globalenv->numChildren() - 1; i >= 0; --i) {
- globalenv->removeChild(globalenv->findChildByIndex(i), true);
+ auto obj = globalenv->findChildByIndex(i);
+ RK_ASSERT(obj->editors().isEmpty());
+ RKModificationTracker::instance()->removeObject(obj, nullptr, true);
}
object_list->updateEnvironments(QStringList() << ".GlobalEnv", false);
object_list->updateNamespaces(QStringList());
- // TODO: For unkonwn reasons, a ghost object remains inside globalenv in the QSortFilterProxyModel (qt 5.12.8). Get rid of it with a model reset
- RKModificationTracker::instance()->beginResetModel();
- RKModificationTracker::instance()->endResetModel();
}
}
diff --git a/rkward/rkward.cpp b/rkward/rkward.cpp
index d2a7b870..75683dfa 100644
--- a/rkward/rkward.cpp
+++ b/rkward/rkward.cpp
@@ -615,8 +615,14 @@ void RKWardMainWindow::initActions() {
auto restart_r = actionCollection()->addAction("restart_r");
restart_r->setText(i18n("Restart R Backend"));
connect(restart_r, &QAction::triggered, this, [this]() {
- if (RInterface::instance()->backendIsDead()) {
+ bool pending = !RInterface::instance()->backendIsDead() && !RInterface::instance()->backendIsIdle();
+ QString add = pending ? i18n("<p>One or more operations are pending, and will be canceled. If you have recently chosen to save your workspace, and you see this messsage, <b>your data may not be saved, yet!</b></p>") : QString();
+ QString message = i18n("<p>This feature is primarily targetted at package developers, who know what they are doing. Please proceed with caution.</p><p><b>All unsaved data in this workspace will be lost!</b> All data editors, and graphics windows will be closed.</p>%1<p>Are you sure you want to proceed?</p>", add);
+ if (KMessageBox::warningContinueCancel(this, message, i18n("Restart R backend"), KGuiItem("Restart R backend now"), KGuiItem("Cancel")) == KMessageBox::Continue) {
+ RKWorkplace::mainWorkplace()->closeAll(RKMDIWindow::X11Window);
+ slotCloseAllEditors();
delete RInterface::instance();
+ RKWorkplace::mainWorkplace()->setWorkspaceURL(QUrl());
startR();
}
});
More information about the rkward-tracker
mailing list