From 4a83ce611d91348903882eafe34c35f44bee1776 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 17 Jun 2014 08:53:34 -0700 Subject: Move most of the QLibraryPrivate initialization to its constructor This commit moves the setting of the loadHints to inside the constructor or to QLibraryStore::findOrCreate (which is under a mutex). This avoids data race conditions with two threads asking for the same plugin at the same time, with different load hints. This also opportunistically moves the setting of the error message for empty file names. Task-number: QTBUG-39642 Change-Id: I497a41781d10e407d6420116a0b05fdfe2b548de Reviewed-by: David Faure --- src/corelib/plugin/qpluginloader.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/corelib/plugin/qpluginloader.cpp') diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp index e4a1d725ec..2c139669e6 100644 --- a/src/corelib/plugin/qpluginloader.cpp +++ b/src/corelib/plugin/qpluginloader.cpp @@ -352,11 +352,8 @@ void QPluginLoader::setFileName(const QString &fileName) else fn = locatePlugin(fileName); - d = QLibraryPrivate::findOrCreate(fn); - d->loadHints = lh; - if (fn.isEmpty()) - d->errorString = QLibrary::tr("The shared library was not found."); - else + d = QLibraryPrivate::findOrCreate(fn, QString(), lh); + if (!fn.isEmpty()) d->updatePluginState(); #else -- cgit v1.2.3