Don't try to unload a library that isn't loaded

Both QPluginLoader::unload() and QLibrary::unload() protect against
that (they have a "did_load" member), but QFactoryLoaderPrivate's
destructor doesn't. In the past (Qt4) all plugins had to be loaded
anyway, so there was no mistake in the reference counting. With Qt 5,
we don't load plugins unless they're actually used (in
QFactoryLoader::instance).

Task-number: QTBUG-29773
Change-Id: I3278fa14bac7e26a9faaf999b4e42e950654ac9a
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
Thiago Macieira 2013-02-20 14:33:46 -08:00 committed by The Qt Project
parent f92e844b2b
commit 2c51bc0289

View File

@ -502,7 +502,7 @@ bool QLibraryPrivate::unload(UnloadFlag flag)
{
if (!pHnd)
return false;
if (!libraryUnloadCount.deref()) { // only unload if ALL QLibrary instance wanted to
if (libraryUnloadCount.load() > 0 && !libraryUnloadCount.deref()) { // only unload if ALL QLibrary instance wanted to
delete inst.data();
if (flag == NoUnloadSys || unload_sys()) {
if (qt_debug_component())