summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/scriptengine.cpp
diff options
context:
space:
mode:
authorArttu Tarkiainen <arttu.tarkiainen@qt.io>2021-01-28 18:00:20 +0200
committerArttu Tarkiainen <arttu.tarkiainen@qt.io>2021-02-04 14:27:15 +0200
commita7b0eead83379d9343429a37efa8e39f924e8525 (patch)
tree1ede0a98dec8dbd9c3503872990e36c850a4380c /src/libs/installer/scriptengine.cpp
parent8dcc1bb8ceabcd30dd3c73c2f9fa23393f6602a8 (diff)
CLI: Exit when expecting user input and the output device is not a TTY
- For arbitrary text input queries, fail and exit. - For file/directory queries, fail and exit. - For message boxes, default to negative option and exit if necessary. Task-number: QTIFW-1949 Change-Id: Iaf8a07247a0e358d4544a856788e48447c6720d9 Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src/libs/installer/scriptengine.cpp')
-rw-r--r--src/libs/installer/scriptengine.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libs/installer/scriptengine.cpp b/src/libs/installer/scriptengine.cpp
index ae5bed72c..5dd56939c 100644
--- a/src/libs/installer/scriptengine.cpp
+++ b/src/libs/installer/scriptengine.cpp
@@ -31,6 +31,7 @@
#include "errors.h"
#include "scriptengine_p.h"
#include "systeminfo.h"
+#include "loggingutils.h"
#include <QMetaEnum>
#include <QQmlEngine>
@@ -344,7 +345,7 @@ QString QFileDialogProxy::getExistingFileOrDirectory(const QString &caption,
.arg(identifier, selectedDirectoryOrFile);
selectedDirectoryOrFile = QString();
}
- } else {
+ } else if (!LoggingHandler::instance().outputRedirected()) {
qDebug().nospace().noquote() << identifier << ": " << caption << ": ";
QTextStream stream(stdin);
stream.readLineInto(&selectedDirectoryOrFile);
@@ -358,6 +359,12 @@ QString QFileDialogProxy::getExistingFileOrDirectory(const QString &caption,
.arg(selectedDirectoryOrFile);
selectedDirectoryOrFile = QString();
}
+ } else {
+ qCDebug(QInstaller::lcInstallerInstallLog).nospace()
+ << "No answer available for "<< identifier << ": " << caption;
+
+ throw Error(tr("User input is required but the output "
+ "device is not associated with a terminal."));
}
if (!errorString.isEmpty())
qCWarning(QInstaller::lcInstallerInstallLog).nospace() << errorString;