Add a way for QtDBus to force a call to dbus_shutdown
This will ask the D-Bus library to free its caches. It's useful for running valgrind on a D-Bus based application, so we can detect real leaks. We can't run this by default because there could be other users of libdbus-1. Calling the shutdown function would make them stop working. Change-Id: I9854b82afcdbc4955d6f0a1a1b49a673186242c8 Reviewed-by: Lorn Potter <lorn.potter@nokia.com>
This commit is contained in:
parent
292350f70d
commit
98437f0e2e
@ -12,7 +12,7 @@ MODULE_CONFIG = dbusadaptors dbusinterfaces
|
|||||||
|
|
||||||
DEFINES += DBUS_API_SUBJECT_TO_CHANGE
|
DEFINES += DBUS_API_SUBJECT_TO_CHANGE
|
||||||
QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS
|
QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS
|
||||||
contains(QT_CONFIG, dbus-linked) {
|
contains(QT_CONFIG, dbus-linked) {
|
||||||
LIBS_PRIVATE += $$QT_LIBS_DBUS
|
LIBS_PRIVATE += $$QT_LIBS_DBUS
|
||||||
DEFINES += QT_LINKED_LIBDBUS
|
DEFINES += QT_LINKED_LIBDBUS
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,8 @@
|
|||||||
|
|
||||||
#ifndef QT_NO_DBUS
|
#ifndef QT_NO_DBUS
|
||||||
|
|
||||||
|
extern "C" void dbus_shutdown();
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
void (*qdbus_resolve_me(const char *name))();
|
void (*qdbus_resolve_me(const char *name))();
|
||||||
@ -59,6 +61,11 @@ static QLibrary *qdbus_libdbus = 0;
|
|||||||
|
|
||||||
void qdbus_unloadLibDBus()
|
void qdbus_unloadLibDBus()
|
||||||
{
|
{
|
||||||
|
if (qdbus_libdbus) {
|
||||||
|
if (qEnvironmentVariableIsSet("QDBUS_FORCE_SHUTDOWN"))
|
||||||
|
qdbus_libdbus->resolve("dbus_shutdown")();
|
||||||
|
qdbus_libdbus->unload();
|
||||||
|
}
|
||||||
delete qdbus_libdbus;
|
delete qdbus_libdbus;
|
||||||
qdbus_libdbus = 0;
|
qdbus_libdbus = 0;
|
||||||
}
|
}
|
||||||
@ -129,12 +136,19 @@ void (*qdbus_resolve_me(const char *name))()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else // QT_LINKED_LIBDBUS
|
||||||
|
static void qdbus_unloadLibDBus()
|
||||||
|
{
|
||||||
|
if (qEnvironmentVariableIsSet("QDBUS_FORCE_SHUTDOWN"))
|
||||||
|
dbus_shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // !QT_LINKED_LIBDBUS
|
||||||
|
|
||||||
#ifndef QT_BOOTSTRAPPED
|
#ifndef QT_BOOTSTRAPPED
|
||||||
Q_DESTRUCTOR_FUNCTION(qdbus_unloadLibDBus)
|
Q_DESTRUCTOR_FUNCTION(qdbus_unloadLibDBus)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // QT_LINKED_LIBDBUS
|
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif // QT_NO_DBUS
|
#endif // QT_NO_DBUS
|
||||||
|
Loading…
Reference in New Issue
Block a user