forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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\".")
|
||||
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();
|
||||
});
|
||||
QObject::connect(process, &QtcProcess::finished, process, &QObject::deleteLater);
|
||||
process->start();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user