diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2022-01-20 11:23:31 +0100 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2022-01-20 11:04:26 +0000 |
commit | 2e3d32cc1bcdd946c1f377ba0abe75044317e0c8 (patch) | |
tree | 53cfeb3801b01a174e920096f3594f4e7d58fbf3 /src/plugins/python/pythonutils.cpp | |
parent | c819c90368c43e965d9018bbc6bc80ed4ca83c40 (diff) | |
download | qt-creator-2e3d32cc1bcdd946c1f377ba0abe75044317e0c8.tar.gz |
PythonEditor: Fix a leak of console process on shutdown
Give a parent for console process in order to delete it
on shutdown. In case the console process was started
and the user closed the Creator we were leaking
console process instance together with its process.
Connect to ConsoleProcess::finished() instead of stubStopped().
There is no point to keep the console open when the process
finished (it forces the user to manually close the stub
window by pressing enter).
Change-Id: I3f14e940f39b32e11bde276e80f3cb630b13d8f7
Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/python/pythonutils.cpp')
-rw-r--r-- | src/plugins/python/pythonutils.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp index d13a233750..17304271a8 100644 --- a/src/plugins/python/pythonutils.cpp +++ b/src/plugins/python/pythonutils.cpp @@ -95,7 +95,7 @@ static QStringList replImportArgs(const FilePath &pythonFile, ReplType type) return {"-c", QString("%1; print('Running \"%1\"')").arg(import)}; } -void openPythonRepl(const FilePath &file, ReplType type) +void openPythonRepl(QObject *parent, const FilePath &file, ReplType type) { static const auto workingDir = [](const FilePath &file) { if (file.isEmpty()) { @@ -107,7 +107,7 @@ void openPythonRepl(const FilePath &file, ReplType type) }; const auto args = QStringList{"-i"} + replImportArgs(file, type); - auto process = new ConsoleProcess; + auto process = new ConsoleProcess(parent); const FilePath pythonCommand = detectPython(file); process->setCommand({pythonCommand, args}); process->setWorkingDirectory(workingDir(file)); @@ -122,7 +122,7 @@ void openPythonRepl(const FilePath &file, ReplType type) .arg(commandLine, process->errorString())); process->deleteLater(); }); - QObject::connect(process, &ConsoleProcess::stubStopped, process, &QObject::deleteLater); + QObject::connect(process, &ConsoleProcess::finished, process, &QObject::deleteLater); process->start(); } |