From 973dbaed98aedeb95ef1841922e42823c914a09c Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 4 Oct 2023 15:15:57 +0200 Subject: [PATCH] PyDapEngine: Start install process directly from the main thread There is no need to start it from a separate thread. Change-Id: I0f560345ed0f02832176a8986a9fbdd97061d3ae Reviewed-by: Qt CI Bot Reviewed-by: Artem Sokolovskii --- src/plugins/debugger/dap/pydapengine.cpp | 19 +++++-------------- src/plugins/debugger/dap/pydapengine.h | 2 ++ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/plugins/debugger/dap/pydapengine.cpp b/src/plugins/debugger/dap/pydapengine.cpp index 01ec0f4dcd3..2257aab76ad 100644 --- a/src/plugins/debugger/dap/pydapengine.cpp +++ b/src/plugins/debugger/dap/pydapengine.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #include @@ -200,16 +199,6 @@ void PyDapEngine::quitDebugger() DebuggerEngine::quitDebugger(); } -void installDebugpyPackage(const FilePath &pythonPath) -{ - CommandLine cmd{pythonPath, {"-m", "pip", "install", "debugpy"}}; - Process process; - process.setCommand(cmd); - process.setTerminalMode(TerminalMode::Run); - process.start(); - process.waitForFinished(); -} - bool PyDapEngine::acceptsBreakpoint(const BreakpointParameters &bp) const { return bp.fileName.endsWith(".py"); @@ -269,9 +258,11 @@ void PyDapEngine::setupEngine() info.addCustomButton(Tr::tr("Install debugpy"), [this] { Core::ICore::infoBar()->removeInfo(installDebugPyInfoBarId); Core::ICore::infoBar()->globallySuppressInfo(installDebugPyInfoBarId); - QTimer::singleShot(0, this, [interpreter = runParameters().interpreter] { - Utils::asyncRun(&installDebugpyPackage, interpreter); - }); + m_installProcess.reset(new Process); + m_installProcess->setCommand({runParameters().interpreter, + {"-m", "pip", "install", "debugpy"}}); + m_installProcess->setTerminalMode(TerminalMode::Run); + m_installProcess->start(); }); Core::ICore::infoBar()->addInfo(info); diff --git a/src/plugins/debugger/dap/pydapengine.h b/src/plugins/debugger/dap/pydapengine.h index 1339c7f971a..2c5f53e63a9 100644 --- a/src/plugins/debugger/dap/pydapengine.h +++ b/src/plugins/debugger/dap/pydapengine.h @@ -27,6 +27,8 @@ private: /* Needed for Python support issue:1386 */ const QLoggingCategory &logCategory() override; + + std::unique_ptr m_installProcess; }; } // Debugger::Internal