diff options
author | Andre Moreira Magalhaes (andrunko) <andre.magalhaes@collabora.co.uk> | 2010-12-30 14:46:38 -0200 |
---|---|---|
committer | Andre Moreira Magalhaes (andrunko) <andre.magalhaes@collabora.co.uk> | 2010-12-31 11:20:39 -0200 |
commit | 5162f291c8c4df953286868abec7ad8876d9f543 (patch) | |
tree | 7787c2cc0a2e6aa0b4f0ad88f99d64f19c4501ab | |
parent | fbbcd582657e5f863df981d91cfee7750b6fa68c (diff) |
Connection: Don't leak contact list group channels.
-rw-r--r-- | TelepathyQt4/connection.cpp | 6 | ||||
-rw-r--r-- | TelepathyQt4/contact-manager.cpp | 14 | ||||
-rw-r--r-- | TelepathyQt4/contact-manager.h | 2 |
3 files changed, 22 insertions, 0 deletions
diff --git a/TelepathyQt4/connection.cpp b/TelepathyQt4/connection.cpp index e704dd53..2d0fda54 100644 --- a/TelepathyQt4/connection.cpp +++ b/TelepathyQt4/connection.cpp @@ -327,6 +327,8 @@ Connection::Private::Private(Connection *parent, Connection::Private::~Private() { + contactManager->resetContactListChannels(); + // Clear selfContact so its handle will be released cleanly before the // handleContext selfContact.reset(); @@ -1950,6 +1952,10 @@ void Connection::onNewChannels(const Tp::ChannelDetailsList &channelDetailsList) ChannelPtr channel = Channel::create(ConnectionPtr(this), channelDetails.channel.path(), channelDetails.properties); mPriv->contactListGroupChannels.append(channel); + // deref connection refcount here as connection will keep a ref to channel and we don't + // want a contact list group channel keeping a ref of connection, otherwise connection will + // leak, thus the channels. + channel->connection()->deref(); connect(channel->becomeReady(), SIGNAL(finished(Tp::PendingOperation*)), SLOT(onContactListGroupChannelReady(Tp::PendingOperation*))); diff --git a/TelepathyQt4/contact-manager.cpp b/TelepathyQt4/contact-manager.cpp index d49d9415..fb5c4b62 100644 --- a/TelepathyQt4/contact-manager.cpp +++ b/TelepathyQt4/contact-manager.cpp @@ -132,6 +132,7 @@ struct TELEPATHY_QT4_NO_EXPORT ContactManager::Private ChannelPtr storedChannel; ChannelPtr denyChannel; QMap<QString, ChannelPtr> contactListGroupChannels; + QList<ChannelPtr> removedContactListGroupChannels; // avatar UIntList requestAvatarsQueue; @@ -2098,6 +2099,8 @@ void ContactManager::onContactListGroupRemovedFallback(Tp::DBusProxy *proxy, QString id = contactListGroupChannel->immutableProperties().value( QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetID")).toString(); mPriv->contactListGroupChannels.remove(id); + mPriv->removedContactListGroupChannels.append(contactListGroupChannel); + disconnect(contactListGroupChannel.data(), 0, 0, 0); emit groupRemoved(id); } @@ -2276,6 +2279,17 @@ void ContactManager::addContactListGroupChannelFallback( emit groupAdded(id); } +void ContactManager::resetContactListChannels() +{ + mPriv->contactListChannels.clear(); + mPriv->subscribeChannel.reset(); + mPriv->publishChannel.reset(); + mPriv->storedChannel.reset(); + mPriv->denyChannel.reset(); + mPriv->contactListGroupChannels.clear(); + mPriv->removedContactListGroupChannels.clear(); +} + QString ContactManager::featureToInterface(const Feature &feature) { if (feature == Contact::FeatureAlias) { diff --git a/TelepathyQt4/contact-manager.h b/TelepathyQt4/contact-manager.h index a676c386..75d3cb63 100644 --- a/TelepathyQt4/contact-manager.h +++ b/TelepathyQt4/contact-manager.h @@ -248,6 +248,8 @@ private: void addContactListGroupChannelFallback( const ChannelPtr &contactListGroupChannel); + void resetContactListChannels(); + static QString featureToInterface(const Feature &feature); struct Private; |