From 3ed5b5ebf5b360dedbba14c03f6ca5701b3b9290 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 18 Aug 2009 19:22:52 +0200 Subject: Remove a global destructor from QtDBus. Instead, only run the unload code if we successfully loaded. --- src/dbus/qdbus_symbols.cpp | 10 ++++++---- 1 file 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 #include #include @@ -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 -- cgit v0.12