diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2009-08-21 16:00:10 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2009-08-21 16:02:36 (GMT) |
commit | fdc159ad6fd03d0e179e7dde7fe47e592936573c (patch) | |
tree | 0ece8f4847cd3e15b06b35d5670a424d2d24fea5 /src/dbus | |
parent | 646da79a07166d7d1ec76983d38ad2270db76754 (diff) | |
download | Qt-fdc159ad6fd03d0e179e7dde7fe47e592936573c.zip Qt-fdc159ad6fd03d0e179e7dde7fe47e592936573c.tar.gz Qt-fdc159ad6fd03d0e179e7dde7fe47e592936573c.tar.bz2 |
Revert "Remove a global destructor from QtDBus."
This reverts commit 3ed5b5ebf5b360dedbba14c03f6ca5701b3b9290. That was
a well-intentioned commit and technically correct, but it breaks when
there are static QDBusConnection objects in something that is loaded
before QtDBus (like libraries that depend on QtDBus or applications
like qdbus)
Since QDBusConnection is ref-counted, the last instance is supposed to
disconnect. However, if we have already unloaded libdbus-1, we can't
do that. Q_GLOBAL_STATICs are destroyed too soon.
Diffstat (limited to 'src/dbus')
-rw-r--r-- | src/dbus/qdbus_symbols.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/dbus/qdbus_symbols.cpp b/src/dbus/qdbus_symbols.cpp index 356b14c..ca0147a 100644 --- a/src/dbus/qdbus_symbols.cpp +++ b/src/dbus/qdbus_symbols.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ -#include "qdbus_symbols_p.h" #include <QtCore/qglobal.h> #include <QtCore/qlibrary.h> #include <QtCore/qmutex.h> @@ -53,7 +52,7 @@ void *qdbus_resolve_me(const char *name); static QLibrary *qdbus_libdbus = 0; -static void qdbus_unloadLibDBus() +void qdbus_unloadLibDBus() { delete qdbus_libdbus; qdbus_libdbus = 0; @@ -77,11 +76,8 @@ 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")) { - struct Unloader { ~Unloader() { qdbus_unloadLibDBus(); } }; - static Unloader unloader; + if (lib->load() && lib->resolve("dbus_connection_open_private")) return true; - } lib->unload(); } @@ -111,6 +107,8 @@ void *qdbus_resolve_me(const char *name) return ptr; } +Q_DESTRUCTOR_FUNCTION(qdbus_unloadLibDBus) + QT_END_NAMESPACE #endif |