summaryrefslogtreecommitdiff
path: root/src/plugins/python/pythonutils.cpp
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2022-04-06 16:54:56 +0200
committerJarek Kobus <jaroslaw.kobus@qt.io>2022-04-27 06:26:45 +0000
commit74b1623acdcd04fc34812560dbcf8136833b9f3a (patch)
tree901019e14f50f9e7e89f61f58735ead0b119f10c /src/plugins/python/pythonutils.cpp
parent8d2c9aa8d4e6e9644d8257173592102f4b89553d (diff)
downloadqt-creator-74b1623acdcd04fc34812560dbcf8136833b9f3a.tar.gz
PythonUtils: Connect to QtcProcess::done() signal
Instead of connecting to errorOccurred() and finished() signals. Change-Id: I02fefe01cfc4be6ef996c7c8b98b36137217504e Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Diffstat (limited to 'src/plugins/python/pythonutils.cpp')
-rw-r--r--src/plugins/python/pythonutils.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp
index cd88efe8f2..713c48821e 100644
--- a/src/plugins/python/pythonutils.cpp
+++ b/src/plugins/python/pythonutils.cpp
@@ -113,17 +113,16 @@ void openPythonRepl(QObject *parent, const FilePath &file, ReplType type)
process->setCommand({pythonCommand, args});
process->setWorkingDirectory(workingDir(file));
const QString commandLine = process->commandLine().toUserOutput();
- QObject::connect(process,
- &QtcProcess::errorOccurred,
- process,
- [process, commandLine] {
- Core::MessageManager::writeDisrupting(
- QCoreApplication::translate("Python",
- "Failed to run Python (%1): \"%2\".")
- .arg(commandLine, process->errorString()));
- process->deleteLater();
- });
- QObject::connect(process, &QtcProcess::finished, process, &QObject::deleteLater);
+ QObject::connect(process, &QtcProcess::done, process, [process, commandLine] {
+ if (process->error() != QProcess::UnknownError) {
+ Core::MessageManager::writeDisrupting(QCoreApplication::translate("Python",
+ (process->error() == QProcess::FailedToStart)
+ ? "Failed to run Python (%1): \"%2\"."
+ : "Error while running Python (%1): \"%2\".")
+ .arg(commandLine, process->errorString()));
+ }
+ process->deleteLater();
+ });
process->start();
}