From 74b1623acdcd04fc34812560dbcf8136833b9f3a Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 6 Apr 2022 16:54:56 +0200 Subject: [PATCH] PythonUtils: Connect to QtcProcess::done() signal Instead of connecting to errorOccurred() and finished() signals. Change-Id: I02fefe01cfc4be6ef996c7c8b98b36137217504e Reviewed-by: David Schulz Reviewed-by: --- src/plugins/python/pythonutils.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp index cd88efe8f20..713c48821ec 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(); }