diff options
author | Marcus Tillmanns <marcus.tillmanns@qt.io> | 2023-05-04 08:09:40 +0200 |
---|---|---|
committer | Marcus Tillmanns <marcus.tillmanns@qt.io> | 2023-05-04 10:43:36 +0000 |
commit | e6081aaa0a845a3cb9af1e4ff9cc8278aca2c276 (patch) | |
tree | 2e713b9cbf24cd66b2b780f7e511ffcfa354cbbb /src/plugins/python/pythonutils.cpp | |
parent | a059f87754c68aec9095b092f23a8cab325a5dfc (diff) | |
download | qt-creator-e6081aaa0a845a3cb9af1e4ff9cc8278aca2c276.tar.gz |
Utils: Add TerminalMode::Detached
Change-Id: Ic36845d3469719e17f24602ce80f3e6cfc984fbf
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/python/pythonutils.cpp')
-rw-r--r-- | src/plugins/python/pythonutils.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp index 0fb4d03f19..bf3f683dd1 100644 --- a/src/plugins/python/pythonutils.cpp +++ b/src/plugins/python/pythonutils.cpp @@ -106,6 +106,8 @@ static QStringList replImportArgs(const FilePath &pythonFile, ReplType type) void openPythonRepl(QObject *parent, const FilePath &file, ReplType type) { + Q_UNUSED(parent) + static const auto workingDir = [](const FilePath &file) { if (file.isEmpty()) { if (Project *project = ProjectManager::startupProject()) @@ -116,23 +118,21 @@ void openPythonRepl(QObject *parent, const FilePath &file, ReplType type) }; const auto args = QStringList{"-i"} + replImportArgs(file, type); - auto process = new Process(parent); - process->setTerminalMode(TerminalMode::On); const FilePath pythonCommand = detectPython(file); - process->setCommand({pythonCommand, args}); - process->setWorkingDirectory(workingDir(file)); - const QString commandLine = process->commandLine().toUserOutput(); - QObject::connect(process, &Process::done, process, [process, commandLine] { - if (process->error() != QProcess::UnknownError) { - Core::MessageManager::writeDisrupting(Tr::tr( - (process->error() == QProcess::FailedToStart) - ? "Failed to run Python (%1): \"%2\"." - : "Error while running Python (%1): \"%2\".") - .arg(commandLine, process->errorString())); - } - process->deleteLater(); - }); - process->start(); + + Process process; + process.setCommand({pythonCommand, args}); + process.setWorkingDirectory(workingDir(file)); + process.setTerminalMode(TerminalMode::Detached); + process.start(); + + if (process.error() != QProcess::UnknownError) { + Core::MessageManager::writeDisrupting( + Tr::tr((process.error() == QProcess::FailedToStart) + ? "Failed to run Python (%1): \"%2\"." + : "Error while running Python (%1): \"%2\".") + .arg(process.commandLine().toUserOutput(), process.errorString())); + } } QString pythonName(const FilePath &pythonPath) |