summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2017-04-01 16:23:06 +0200
committerSlávek Banko <slavek.banko@axis.cz>2017-04-01 16:23:06 +0200
commit9d505d268352b7776a80dc91b7e49fc4c73a5e73 (patch)
tree27e5140486ae7b7390328d8951a537878a6e7464
parentc30d6781767619d5972b102e88bc6e51b9279031 (diff)
downloaddbus-1-tqt-9d505d268352b7776a80dc91b7e49fc4c73a5e73.tar.gz
dbus-1-tqt-9d505d268352b7776a80dc91b7e49fc4c73a5e73.zip
Fix memory leaks in sendWithReplyAsync
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
-rw-r--r--tqdbusintegrator.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/tqdbusintegrator.cpp b/tqdbusintegrator.cpp
index 9da40c8..c7129bd 100644
--- a/tqdbusintegrator.cpp
+++ b/tqdbusintegrator.cpp
@@ -291,6 +291,16 @@ TQT_DBusConnectionPrivate::TQT_DBusConnectionPrivate(TQObject *parent)
TQT_DBusConnectionPrivate::~TQT_DBusConnectionPrivate()
{
+ for (PendingCallMap::iterator it = pendingCalls.begin(); it != pendingCalls.end();)
+ {
+ PendingCallMap::iterator copyIt = it;
+ ++it;
+ dbus_pending_call_cancel(copyIt.key());
+ dbus_pending_call_unref(copyIt.key());
+ delete copyIt.data();
+ pendingCalls.erase(copyIt);
+ }
+
if (dbus_error_is_set(&error))
dbus_error_free(&error);
@@ -629,20 +639,22 @@ int TQT_DBusConnectionPrivate::sendWithReplyAsync(const TQT_DBusMessage &message
if (!msg)
return 0;
+ int msg_serial = 0;
DBusPendingCall *pending = 0;
if (dbus_connection_send_with_reply(connection, msg, &pending, message.timeout())) {
TQT_DBusPendingCall *pcall = new TQT_DBusPendingCall;
pcall->receiver = receiver;
pcall->method = method;
- pcall->pending = dbus_pending_call_ref(pending);
+ pcall->pending = pending;
pendingCalls.insert(pcall->pending, pcall);
dbus_pending_call_set_notify(pending, qDBusResultReceived, this, 0);
- return dbus_message_get_serial(msg);
+ msg_serial = dbus_message_get_serial(msg);
}
- return 0;
+ dbus_message_unref(msg);
+ return msg_serial;
}
void TQT_DBusConnectionPrivate::flush()