From 2c51bc0289e5f4a8a2cfb4a57562633c1018ab58 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 20 Feb 2013 14:33:46 -0800 Subject: 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 Reviewed-by: Lars Knoll --- src/corelib/plugin/qlibrary.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/plugin') diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index 236832097a..1e17c9fbd4 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -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()) -- cgit v1.2.3