diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2014-07-21 16:36:24 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2014-07-23 17:50:23 +0200 |
commit | cfaf851e268dac95cb140fbffc1233981ce48d4c (patch) | |
tree | 0a8ae098f6636fa301c48c3c17a4e9fefdb1e184 /src/corelib/plugin/qpluginloader.cpp | |
parent | 800d0076e0adaeb751f7040fbd7476292e1a2af9 (diff) |
Fix a few more race conditions with QLibrary::LoadHints
This commit makes replaces the loadHints member with a setter, a getter
and an atomic variable. The setter will not set anything if the library
has already been loaded.
Task-number: QTBUG-39642
Change-Id: Ibb7692f16d80211b52aaf4dc88db1a989738a24d
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/corelib/plugin/qpluginloader.cpp')
-rw-r--r-- | src/corelib/plugin/qpluginloader.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp index 2c139669e6..f34c019823 100644 --- a/src/corelib/plugin/qpluginloader.cpp +++ b/src/corelib/plugin/qpluginloader.cpp @@ -339,7 +339,7 @@ void QPluginLoader::setFileName(const QString &fileName) #if defined(QT_SHARED) QLibrary::LoadHints lh; if (d) { - lh = d->loadHints; + lh = d->loadHints(); d->release(); d = 0; did_load = false; @@ -405,17 +405,12 @@ void QPluginLoader::setLoadHints(QLibrary::LoadHints loadHints) d = QLibraryPrivate::findOrCreate(QString()); // ugly, but we need a d-ptr d->errorString.clear(); } - d->loadHints = loadHints; + d->setLoadHints(loadHints); } QLibrary::LoadHints QPluginLoader::loadHints() const { - if (!d) { - QPluginLoader *that = const_cast<QPluginLoader *>(this); - that->d = QLibraryPrivate::findOrCreate(QString()); // ugly, but we need a d-ptr - that->d->errorString.clear(); - } - return d->loadHints; + return d ? d->loadHints() : QLibrary::LoadHints(); } /*! |