lock QFactoryLoader on write instead of read

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-02-01 09:12:06 +02:00
parent 66bb5f237c
commit 92e2ca32b5

View file

@ -185,6 +185,7 @@ void QFactoryLoader::updateDir(const QString &pluginDir)
void QFactoryLoader::update() void QFactoryLoader::update()
{ {
Q_D(QFactoryLoader); Q_D(QFactoryLoader);
QMutexLocker locker(&d->mutex);
foreach (const QString &pluginDir, QCoreApplication::libraryPaths()) { foreach (const QString &pluginDir, QCoreApplication::libraryPaths()) {
// Already loaded, skip it... // Already loaded, skip it...
if (d->loadedPaths.contains(pluginDir)) if (d->loadedPaths.contains(pluginDir))
@ -203,7 +204,6 @@ QFactoryLoader::~QFactoryLoader()
QStringList QFactoryLoader::keys() const QStringList QFactoryLoader::keys() const
{ {
Q_D(const QFactoryLoader); Q_D(const QFactoryLoader);
QMutexLocker locker(&d->mutex);
return d->keyList; return d->keyList;
} }