diff --git a/src/plugins/python/pythoneditor.cpp b/src/plugins/python/pythoneditor.cpp index f0e8acab46e..c3e9ec0c51c 100644 --- a/src/plugins/python/pythoneditor.cpp +++ b/src/plugins/python/pythoneditor.cpp @@ -63,9 +63,9 @@ static QAction *createAction(QObject *parent, ReplType type) break; } - QObject::connect(action, &QAction::triggered, parent, [type] { + QObject::connect(action, &QAction::triggered, parent, [type, parent] { Core::IDocument *doc = Core::EditorManager::currentDocument(); - openPythonRepl(doc ? doc->filePath() : Utils::FilePath(), type); + openPythonRepl(parent, doc ? doc->filePath() : Utils::FilePath(), type); }); return action; } diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp index d13a233750b..17304271a84 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(); } diff --git a/src/plugins/python/pythonutils.h b/src/plugins/python/pythonutils.h index 9fa9651b5ff..c33bf456cac 100644 --- a/src/plugins/python/pythonutils.h +++ b/src/plugins/python/pythonutils.h @@ -31,7 +31,7 @@ namespace Python { namespace Internal { enum class ReplType { Unmodified, Import, ImportToplevel }; -void openPythonRepl(const Utils::FilePath &file, ReplType type); +void openPythonRepl(QObject *parent, const Utils::FilePath &file, ReplType type); Utils::FilePath detectPython(const Utils::FilePath &documentPath); } // namespace Internal