forked from qt-creator/qt-creator
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 <david.schulz@qt.io>
This commit is contained in:
@@ -143,20 +143,13 @@ Pip *Pip::instance(const FilePath &python)
|
||||
return it.value();
|
||||
}
|
||||
|
||||
QFuture<PipPackageInfo> 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<PipPackageInfo> Pip::info(const PipPackage &package)
|
||||
{
|
||||
return Utils::runAsync(infoImpl, package, m_python);
|
||||
}
|
||||
|
||||
Pip::Pip(const Utils::FilePath &python)
|
||||
: QObject(PythonPlugin::instance())
|
||||
, m_python(python)
|
||||
|
@@ -55,9 +55,6 @@ public:
|
||||
private:
|
||||
Pip(const Utils::FilePath &python);
|
||||
|
||||
PipPackageInfo infoImpl(const PipPackage &package);
|
||||
|
||||
QMutex m_lock;
|
||||
Utils::FilePath m_python;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user