diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-08-17 18:10:23 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-02 10:35:22 +0100 |
commit | 288d3aceee83192bb84d73c60268a18722488adf (patch) | |
tree | 643b1710f6e8f5d72782b4f05ce70eeae427a7a9 /src/corelib/plugin/qlibrary_p.h | |
parent | 6a5c6b3ce60f8714824f3ce0224885cb694c1aa4 (diff) |
Improve QLibrary global destruction
The previous solution was a global static, which got deleted at the end
of the execution of the application or at QtCore unload, whichever came
first. Unfortunately, the end of the execution often came first, which
is inconvenient: it means the global was deleted before all atexit
functions were run, including some QLibrary destructors.
Consequently, some QLibrary destructors did not reach the global data
and were thus unable to unload their libraries or delete their data
properly. The previous solution leaked.
This solution instead uses a Q_DESTRUCTOR_FUNCTION, which makes a
requirement to destroy only at QtCore unload time. Thus, we're sure that
all references have been dropped.
Additionally, during the cleanup, do try to unload the libraries that
have a single reference count left. That means either a QLibrary that
was destroyed without unload(), or a use of the static QLibrary::resolve
functions.
Change-Id: I12e0943b0c6edc27390c103b368d1b04bfe7e302
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/corelib/plugin/qlibrary_p.h')
-rw-r--r-- | src/corelib/plugin/qlibrary_p.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/plugin/qlibrary_p.h b/src/corelib/plugin/qlibrary_p.h index 28bec300eb..42172167b7 100644 --- a/src/corelib/plugin/qlibrary_p.h +++ b/src/corelib/plugin/qlibrary_p.h @@ -71,6 +71,7 @@ QT_BEGIN_NAMESPACE bool qt_debug_component(); +class QLibraryStore; class QLibraryPrivate { public: @@ -128,7 +129,7 @@ private: QAtomicInt libraryUnloadCount; enum { IsAPlugin, IsNotAPlugin, MightBeAPlugin } pluginState; - friend class QLibraryPrivateHasFriends; + friend class QLibraryStore; }; QT_END_NAMESPACE |