From da7009ac164f7df847739dd63de1e8595825cb9c Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Tue, 4 Apr 2023 15:31:03 +0200 Subject: [PATCH] Python: Remove unneeded mutex The mutex may potentially block concurrent calls to Pip::infoImpl(). Make infoImpl() a static method in cpp. Change-Id: I06e2de08674b5669e58684743d67a569da43d662 Reviewed-by: David Schulz --- src/plugins/python/pipsupport.cpp | 16 +++++++--------- src/plugins/python/pipsupport.h | 3 --- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/plugins/python/pipsupport.cpp b/src/plugins/python/pipsupport.cpp index 848184b462f..a282702d9bd 100644 --- a/src/plugins/python/pipsupport.cpp +++ b/src/plugins/python/pipsupport.cpp @@ -143,20 +143,13 @@ Pip *Pip::instance(const FilePath &python) return it.value(); } -QFuture Pip::info(const PipPackage &package) -{ - return Utils::runAsync(&Pip::infoImpl, this, package); -} - -PipPackageInfo Pip::infoImpl(const PipPackage &package) +static PipPackageInfo infoImpl(const PipPackage &package, const FilePath &python) { PipPackageInfo result; QtcProcess pip; - pip.setCommand(CommandLine(m_python, {"-m", "pip", "show", "-f", package.packageName})); - m_lock.lock(); + pip.setCommand(CommandLine(python, {"-m", "pip", "show", "-f", package.packageName})); pip.runBlocking(); - m_lock.unlock(); QString fieldName; QStringList data; const QString pipOutput = pip.allOutput(); @@ -180,6 +173,11 @@ PipPackageInfo Pip::infoImpl(const PipPackage &package) return result; } +QFuture Pip::info(const PipPackage &package) +{ + return Utils::runAsync(infoImpl, package, m_python); +} + Pip::Pip(const Utils::FilePath &python) : QObject(PythonPlugin::instance()) , m_python(python) diff --git a/src/plugins/python/pipsupport.h b/src/plugins/python/pipsupport.h index e5f53768ce9..4ef6fcca730 100644 --- a/src/plugins/python/pipsupport.h +++ b/src/plugins/python/pipsupport.h @@ -55,9 +55,6 @@ public: private: Pip(const Utils::FilePath &python); - PipPackageInfo infoImpl(const PipPackage &package); - - QMutex m_lock; Utils::FilePath m_python; };