[Telepathy-commits] [telepathy-qt4/master] Fixed issue: text channel was not closed if ChatChannel was deleted

Stefan Eilers stefan.eilers at basyskom.de
Tue Feb 24 04:06:23 PST 2009


---
 TelepathyQt4/Prototype/ChatChannel.cpp |   28 +++++++++++++++++++++++-----
 1 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/TelepathyQt4/Prototype/ChatChannel.cpp b/TelepathyQt4/Prototype/ChatChannel.cpp
index 9586580..aba3480 100644
--- a/TelepathyQt4/Prototype/ChatChannel.cpp
+++ b/TelepathyQt4/Prototype/ChatChannel.cpp
@@ -38,11 +38,21 @@ class TpPrototype::ChatChannelPrivate
 public:
     ChatChannelPrivate()
     { init(); }
+
+    ~ChatChannelPrivate()
+    {
+        // Close channel before deleting objects
+        if ( m_pChannelInterface )
+        { m_pChannelInterface->Close(); }
+        delete m_pTextChannel;
+        delete m_pChannelInterface;
+    }
     
-    QPointer<TpPrototype::Contact>                          m_pContact;
+    QPointer<TpPrototype::Contact>                        m_pContact;
     Telepathy::Client::ChannelTypeTextInterface*          m_pTextChannel;
     QPointer<Telepathy::Client::ConnectionInterface>      m_pConnectionInterface;
-
+    Telepathy::Client::ChannelInterface*                  m_pChannelInterface;
+            
     bool m_isValid;
     bool m_areSignalsConnected;
 
@@ -52,6 +62,7 @@ private:
         m_pContact              = NULL;
         m_pConnectionInterface  = NULL;
         m_pTextChannel          = NULL;
+        m_pChannelInterface     = NULL;
         m_isValid               = true;
         m_areSignalsConnected   = false;
     }
@@ -70,7 +81,7 @@ ChatChannel::ChatChannel( Contact* contact, Telepathy::Client::ConnectionInterfa
 }
 
 ChatChannel::~ChatChannel()
-        { delete d; }
+{ delete d; }
 
 bool ChatChannel::isValid() const
 { return d->m_isValid; }
@@ -153,11 +164,18 @@ void ChatChannel::openTextChannel(uint handle, uint handleType, const QString& c
     d->m_pTextChannel = new Telepathy::Client::ChannelTypeTextInterface( channel_service_name,
                                                                      channel_path,
                                                                      this );
-    if (!d->m_pTextChannel->isValid())
+    d->m_pChannelInterface = new Telepathy::Client::ChannelInterface( channel_service_name,
+                                                                      channel_path,
+                                                                      this );
+    Q_ASSERT( d->m_pChannelInterface->isValid() );
+    Q_ASSERT( d->m_pTextChannel->isValid() );
+    if (!d->m_pTextChannel->isValid() || !d->m_pChannelInterface->isValid())
     {
-        qDebug() << "Failed to connect channel interface class to D-Bus object.";
+        qDebug() << "Failed to connect channel interface classes to D-Bus object.";
         delete d->m_pTextChannel;
+        delete d->m_pChannelInterface;
         d->m_pTextChannel = NULL;
+        d->m_pChannelInterface = NULL;
         d->m_isValid = false;
         return;
     }
-- 
1.5.6.5




More information about the telepathy-commits mailing list