summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2015-01-01 22:06:18 -0200
committerThiago Macieira <thiago.macieira@intel.com>2015-01-11 03:39:40 +0100
commitfb166648936410f791ae6e600756d255b4a50545 (patch)
treeb28dce8b7f28a8b933268478610e66b86c43de74 /src
parenta90bb5b89a09490a1795064133f6d8ce33b6874e (diff)
Fix memory leaks with QDBusServer
Two serious mistakes: - we need to call dbus_server_free_data_slot as many times as we call dbus_server_allocate_data_slot - we need to delete the d pointer... The changes to the unit tests are simply to cause the used peer connections to be removed so they don't show up in valgrind. Change-Id: I9fd1ada5503db9ba481806c09116874ee81f450d Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/dbus/qdbus_symbols_p.h2
-rw-r--r--src/dbus/qdbusintegrator.cpp9
-rw-r--r--src/dbus/qdbusserver.cpp1
3 files changed, 9 insertions, 3 deletions
diff --git a/src/dbus/qdbus_symbols_p.h b/src/dbus/qdbus_symbols_p.h
index 0785fea4b4..4bec3af490 100644
--- a/src/dbus/qdbus_symbols_p.h
+++ b/src/dbus/qdbus_symbols_p.h
@@ -323,6 +323,8 @@ DEFINEFUNC(void , dbus_pending_call_unref, (DBusPendingCall
/* dbus-server.h */
DEFINEFUNC(dbus_bool_t , dbus_server_allocate_data_slot, (dbus_int32_t *slot_p),
(slot_p), return)
+DEFINEFUNC(void , dbus_server_free_data_slot, (dbus_int32_t *slot_p),
+ (slot_p), return)
DEFINEFUNC(void , dbus_server_disconnect, (DBusServer *server),
(server), )
DEFINEFUNC(char* , dbus_server_get_address, (DBusServer *server),
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index dd92602dce..698fb1b46c 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -66,6 +66,9 @@
QT_BEGIN_NAMESPACE
+// used with dbus_server_allocate_data_slot
+static dbus_int32_t server_slot = -1;
+
static QBasicAtomicInt isDebugging = Q_BASIC_ATOMIC_INITIALIZER(-1);
#define qDBusDebug if (::isDebugging == 0); else qDebug
@@ -1084,8 +1087,10 @@ void QDBusConnectionPrivate::closeConnection()
mode = InvalidMode; // prevent reentrancy
baseService.clear();
- if (server)
+ if (server) {
q_dbus_server_disconnect(server);
+ q_dbus_server_free_data_slot(&server_slot);
+ }
if (oldMode == ClientMode || oldMode == PeerMode) {
if (connection) {
@@ -1651,8 +1656,6 @@ void QDBusConnectionPrivate::handleSignal(const QDBusMessage& msg)
handleSignal(key, msg); // third try
}
-static dbus_int32_t server_slot = -1;
-
void QDBusConnectionPrivate::setServer(DBusServer *s, const QDBusErrorInternal &error)
{
mode = ServerMode;
diff --git a/src/dbus/qdbusserver.cpp b/src/dbus/qdbusserver.cpp
index b2c76a8750..3fec7c9111 100644
--- a/src/dbus/qdbusserver.cpp
+++ b/src/dbus/qdbusserver.cpp
@@ -110,6 +110,7 @@ QDBusServer::~QDBusServer()
}
d->serverConnectionNames.clear();
}
+ d->deleteLater();
}
/*!