summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2013-02-05 13:39:54 -0800
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-07 23:32:05 +0100
commitf79cc2d66b16af40aef7af1803c3ba50c939b03f (patch)
tree15f758377f18e4b2d17514aef4624872ed45b75b /src
parent155a20628b91a7a2e24264feae12f4607574cb6b (diff)
Fix crash-on-exit with some plugin systems (e.g. sensors)
Don't assume that all entries in the QLibrary global data refer to libraries have have been loaded. There are three (not two) ways of getting entries there: 1) creating a QLibrary 2) using the static QLibrary::resolve 3) via plugins The unload code was meant to handle the first two cases only: libraries are still loaded at the end of the execution if the static methods were called or if QLibrary objects were leaked. It didn't handle the case of plugins being found by the directory scanner in QFactoryLoader but never loaded. Note it's possible that this assertion also happened with leaked QLibrary. Change-Id: Idcd7a551f96d8fe500cbca682f8014f5122b7584 Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/plugin/qlibrary.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index 40b6b0d150..236832097a 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -373,17 +373,18 @@ inline void QLibraryStore::cleanup()
for (; it != data->libraryMap.end(); ++it) {
QLibraryPrivate *lib = it.value();
if (lib->libraryRefCount.load() == 1) {
- Q_ASSERT(lib->pHnd);
- Q_ASSERT(lib->libraryUnloadCount.load() > 0);
- lib->libraryUnloadCount.store(1);
+ if (lib->libraryUnloadCount.load() > 0) {
+ Q_ASSERT(lib->pHnd);
+ lib->libraryUnloadCount.store(1);
#ifdef __GLIBC__
- // glibc has a bug in unloading from global destructors
- // see https://bugzilla.novell.com/show_bug.cgi?id=622977
- // and http://sourceware.org/bugzilla/show_bug.cgi?id=11941
- lib->unload(QLibraryPrivate::NoUnloadSys);
+ // glibc has a bug in unloading from global destructors
+ // see https://bugzilla.novell.com/show_bug.cgi?id=622977
+ // and http://sourceware.org/bugzilla/show_bug.cgi?id=11941
+ lib->unload(QLibraryPrivate::NoUnloadSys);
#else
- lib->unload();
+ lib->unload();
#endif
+ }
delete lib;
it.value() = 0;
}