[education/rkward] rkward: Avoid tests hanging on warning message
Thomas Friedrichsmeier
null at kde.org
Mon Jun 24 22:13:02 BST 2024
Git commit 1ca1f368e36a88c7410e070c6fd03ddf0d18a820 by Thomas Friedrichsmeier.
Committed on 22/06/2024 at 21:06.
Pushed by tfry into branch 'master'.
Avoid tests hanging on warning message
M +1 -1 rkward/rbackend/rkrinterface.cpp
M +2 -2 rkward/windows/rkcommandeditorwindow.cpp
M +7 -4 rkward/windows/rkwindowcatcher.cpp
https://invent.kde.org/education/rkward/-/commit/1ca1f368e36a88c7410e070c6fd03ddf0d18a820
diff --git a/rkward/rbackend/rkrinterface.cpp b/rkward/rbackend/rkrinterface.cpp
index 12e6e042b..c20b91f1c 100644
--- a/rkward/rbackend/rkrinterface.cpp
+++ b/rkward/rbackend/rkrinterface.cpp
@@ -854,7 +854,7 @@ void RInterface::processRBackendRequest (RBackendRequest *request) {
RKRBackendProtocolFrontend::setRequestCompleted (request);
return;
} else {
- int result = dialog->exec ();
+ int result = RKWardMainWindow::suppressModalDialogsForTesting() ? QDialogButtonBox::Cancel : dialog->exec();
QString result_string;
if (result == QDialogButtonBox::Yes || result == QDialogButtonBox::Ok) result_string = "yes";
else if (result == QDialogButtonBox::No) result_string = "no";
diff --git a/rkward/windows/rkcommandeditorwindow.cpp b/rkward/windows/rkcommandeditorwindow.cpp
index 217804b0f..79aba32e9 100644
--- a/rkward/windows/rkcommandeditorwindow.cpp
+++ b/rkward/windows/rkcommandeditorwindow.cpp
@@ -642,8 +642,8 @@ void RKCommandEditorWindow::changePreviewMode (QAction *mode) {
RK_TRACE (COMMANDEDITOR);
if (mode != action_no_preview) {
- if (!preview_dir) { // triggered on change from no preview to some preview, but not between previews
- if (KMessageBox::warningContinueCancel (this, i18n ("<p>The preview feature <b>tries</b> to avoid making any lasting changes to your workspace (technically, by making use of a <i>local()</i> evaluation environment). <b>However, there are cases where using the preview feature may cause unexpected side-effects</b>.</p><p>In particular, this is the case for scripts that contain explicit assignments to <i>globalenv()</i>, or to scripts that alter files on your filesystem. Further, attaching/detaching packages or package namespaces will affect the entire running R session.</p><p>Please keep this in mind when using the preview feature, and especially when using the feature on scripts originating from untrusted sources.</p>"), i18n ("Potential side-effects of previews"), KStandardGuiItem::cont (), KStandardGuiItem::cancel (), QStringLiteral ("preview_side_effects")) != KMessageBox::Continue) {
+ if (!(preview_dir || RKWardMainWindow::suppressModalDialogsForTesting())) { // triggered on change from no preview to some preview, but not between previews
+ if (KMessageBox::warningContinueCancel(this, i18n("<p>The preview feature <b>tries</b> to avoid making any lasting changes to your workspace (technically, by making use of a <i>local()</i> evaluation environment). <b>However, there are cases where using the preview feature may cause unexpected side-effects</b>.</p><p>In particular, this is the case for scripts that contain explicit assignments to <i>globalenv()</i>, or to scripts that alter files on your filesystem. Further, attaching/detaching packages or package namespaces will affect the entire running R session.</p><p>Please keep this in mind when using the preview feature, and especially when using the feature on scripts originating from untrusted sources.</p>"), i18n ("Potential side-effects of previews"), KStandardGuiItem::cont(), KStandardGuiItem::cancel(), QStringLiteral("preview_side_effects")) != KMessageBox::Continue) {
discardPreview ();
}
}
diff --git a/rkward/windows/rkwindowcatcher.cpp b/rkward/windows/rkwindowcatcher.cpp
index 301c671b8..93249d88e 100644
--- a/rkward/windows/rkwindowcatcher.cpp
+++ b/rkward/windows/rkwindowcatcher.cpp
@@ -29,6 +29,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include "rkworkplace.h"
#include "../misc/rkstandardicons.h"
#include "../misc/rkcommonfunctions.h"
+#include "../rkward.h"
#include "../debug.h"
RKWindowCatcher *RKWindowCatcher::_instance = nullptr;
@@ -362,10 +363,12 @@ void RKCaughtX11Window::doEmbed () {
}
// try to be helpful when the window is too large to fit on screen
- const QRect dims = window ()->frameGeometry ();
+ const QRect dims = window()->frameGeometry();
const QRect avail = window()->screen() ? window()->screen()->availableGeometry() : QApplication::primaryScreen()->availableGeometry();
- if ((dims.width () > avail.width ()) || (dims.height () > avail.height ())) {
- KMessageBox::information (this, i18n ("The current window appears too large to fit on the screen. If this happens regularly, you may want to adjust the default graphics window size in Settings->Configure RKWard->Onscreen Graphics."), i18n ("Large window"), "dont_ask_again_large_x11_window");
+ if ((dims.width() > avail.width()) || (dims.height() > avail.height())) {
+ if (!RKWardMainWindow::suppressModalDialogsForTesting()) {
+ KMessageBox::information(this, i18n("The current window appears too large to fit on the screen. If this happens regularly, you may want to adjust the default graphics window size in Settings->Configure RKWard->Onscreen Graphics."), i18n("Large window"), "dont_ask_again_large_x11_window");
+ }
}
}
@@ -395,7 +398,7 @@ void RKCaughtX11Window::commonClose(bool in_destructor) {
RInterface::issueCommand(c);
close_attempted = true;
} else {
- if (in_destructor) return;
+ if (in_destructor || RKWardMainWindow::suppressModalDialogsForTesting()) return;
if (KMessageBox::questionTwoActions(this, i18n("<p>The graphics device is being closed, saving the last plot to the plot history. This may take a while, if the R backend is still busy. You can close the graphics device immediately, in case it is stuck. However, the last plot may be missing from the plot history, if you do this.</p>")
#if !defined Q_OS_WIN
+ i18n("<p>Note: On X11, the embedded window may be expurged, and you will have to close it manually in this case.</p>")
More information about the rkward-tracker
mailing list