diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2009-08-18 17:22:52 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2009-08-18 18:18:39 (GMT) |
commit | 3ed5b5ebf5b360dedbba14c03f6ca5701b3b9290 (patch) | |
tree | 7d97324d35e1aa1c0de10093c630988eddbdc023 /src/dbus | |
parent | 8bea43ccb0f53234f87e4aa4d27371b741005222 (diff) | |
download | Qt-3ed5b5ebf5b360dedbba14c03f6ca5701b3b9290.zip Qt-3ed5b5ebf5b360dedbba14c03f6ca5701b3b9290.tar.gz Qt-3ed5b5ebf5b360dedbba14c03f6ca5701b3b9290.tar.bz2 |
Remove a global destructor from QtDBus.
Instead, only run the unload code if we successfully loaded.
Diffstat (limited to 'src/dbus')
-rw-r--r-- | src/dbus/qdbus_symbols.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/dbus/qdbus_symbols.cpp b/src/dbus/qdbus_symbols.cpp index ca0147a..356b14c 100644 --- a/src/dbus/qdbus_symbols.cpp +++ b/src/dbus/qdbus_symbols.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#include "qdbus_symbols_p.h" #include <QtCore/qglobal.h> #include <QtCore/qlibrary.h> #include <QtCore/qmutex.h> @@ -52,7 +53,7 @@ void *qdbus_resolve_me(const char *name); static QLibrary *qdbus_libdbus = 0; -void qdbus_unloadLibDBus() +static void qdbus_unloadLibDBus() { delete qdbus_libdbus; qdbus_libdbus = 0; @@ -76,8 +77,11 @@ bool qdbus_loadLibDBus() lib->setFileName(QLatin1String("dbus-1")); for (uint i = 0; i < sizeof(majorversions) / sizeof(majorversions[0]); ++i) { lib->setFileNameAndVersion(lib->fileName(), majorversions[i]); - if (lib->load() && lib->resolve("dbus_connection_open_private")) + if (lib->load() && lib->resolve("dbus_connection_open_private")) { + struct Unloader { ~Unloader() { qdbus_unloadLibDBus(); } }; + static Unloader unloader; return true; + } lib->unload(); } @@ -107,8 +111,6 @@ void *qdbus_resolve_me(const char *name) return ptr; } -Q_DESTRUCTOR_FUNCTION(qdbus_unloadLibDBus) - QT_END_NAMESPACE #endif |