diff --git a/src/dbus/dbus.pro b/src/dbus/dbus.pro index d7b745d81e..3dd60c8447 100644 --- a/src/dbus/dbus.pro +++ b/src/dbus/dbus.pro @@ -12,7 +12,7 @@ MODULE_CONFIG = dbusadaptors dbusinterfaces DEFINES += DBUS_API_SUBJECT_TO_CHANGE QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS -contains(QT_CONFIG, dbus-linked) { +contains(QT_CONFIG, dbus-linked) { LIBS_PRIVATE += $$QT_LIBS_DBUS DEFINES += QT_LINKED_LIBDBUS } diff --git a/src/dbus/qdbus_symbols.cpp b/src/dbus/qdbus_symbols.cpp index cb2225e0db..4e8249f6d7 100644 --- a/src/dbus/qdbus_symbols.cpp +++ b/src/dbus/qdbus_symbols.cpp @@ -48,6 +48,8 @@ #ifndef QT_NO_DBUS +extern "C" void dbus_shutdown(); + QT_BEGIN_NAMESPACE void (*qdbus_resolve_me(const char *name))(); @@ -59,6 +61,11 @@ static QLibrary *qdbus_libdbus = 0; void qdbus_unloadLibDBus() { + if (qdbus_libdbus) { + if (qEnvironmentVariableIsSet("QDBUS_FORCE_SHUTDOWN")) + qdbus_libdbus->resolve("dbus_shutdown")(); + qdbus_libdbus->unload(); + } delete qdbus_libdbus; qdbus_libdbus = 0; } @@ -129,12 +136,19 @@ void (*qdbus_resolve_me(const char *name))() #endif } +#else // QT_LINKED_LIBDBUS +static void qdbus_unloadLibDBus() +{ + if (qEnvironmentVariableIsSet("QDBUS_FORCE_SHUTDOWN")) + dbus_shutdown(); +} + +#endif // !QT_LINKED_LIBDBUS + #ifndef QT_BOOTSTRAPPED Q_DESTRUCTOR_FUNCTION(qdbus_unloadLibDBus) #endif -#endif // QT_LINKED_LIBDBUS - QT_END_NAMESPACE #endif // QT_NO_DBUS