[Telepathy-commits] [telepathy-qt4/master] Make proxy lifetimes tied to the OptionalInterfaceFactory lifetime

Olli Salli olli.salli at collabora.co.uk
Tue Sep 9 06:56:56 PDT 2008


---
 TelepathyQt4/cli-optional-interface-factory.cpp |   10 ++++++++++
 TelepathyQt4/cli-optional-interface-factory.h   |    4 ++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/TelepathyQt4/cli-optional-interface-factory.cpp b/TelepathyQt4/cli-optional-interface-factory.cpp
index 2c92047..9406fe0 100644
--- a/TelepathyQt4/cli-optional-interface-factory.cpp
+++ b/TelepathyQt4/cli-optional-interface-factory.cpp
@@ -39,10 +39,20 @@ struct OptionalInterfaceFactory::Private
 OptionalInterfaceFactory::OptionalInterfaceFactory()
     : mPriv(new Private())
 {
+    debug() << "Constructing OptionalInterfaceFactory";
 }
 
 OptionalInterfaceFactory::~OptionalInterfaceFactory()
 {
+    debug() << "Destroying OptionalInterfaceFactory";
+
+    for (QMap<QString, QDBusAbstractInterface*>::iterator i = mPriv->interfaces.begin();
+                                                          i != mPriv->interfaces.end();
+                                                          ++i) {
+        debug().nospace() << " ~" << i.key();
+        delete i.value();
+    }
+
     delete mPriv;
 }
 
diff --git a/TelepathyQt4/cli-optional-interface-factory.h b/TelepathyQt4/cli-optional-interface-factory.h
index eff7f22..b388292 100644
--- a/TelepathyQt4/cli-optional-interface-factory.h
+++ b/TelepathyQt4/cli-optional-interface-factory.h
@@ -56,7 +56,7 @@ class OptionalInterfaceFactory
         ~OptionalInterfaceFactory();
 
         template <typename OptionalInterface, typename MainInterface>
-        inline OptionalInterface* interface(MainInterface* mainInterface) const
+        inline OptionalInterface* interface(const MainInterface& mainInterface) const
         {
             // Check that the types given are both subclasses of QDBusAbstractInterface
             QDBusAbstractInterface* mainInterfaceMustBeASubclassOfQDBusAbstractInterface = static_cast<MainInterface*>(NULL);
@@ -71,7 +71,7 @@ class OptionalInterfaceFactory
                 return static_cast<OptionalInterface*>(cached);
 
             // Otherwise, cache and return a newly constructed proxy
-            OptionalInterface* interface = new OptionalInterface(*mainInterface, mainInterface);
+            OptionalInterface* interface = new OptionalInterface(mainInterface, 0);
             cache(interface);
             return interface;
         }
-- 
1.5.6.3




More information about the Telepathy-commits mailing list