[ekiga/ds-fix-boost-leaks] Presence: Simplified signals and signal relays.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga/ds-fix-boost-leaks] Presence: Simplified signals and signal relays.
- Date: Sun, 21 Jun 2015 13:34:44 +0000 (UTC)
commit 782aaa9319dda5d0945d65ed61834bece6a0fd5b
Author: Damien Sandras <dsandras seconix com>
Date: Sat Jun 20 11:41:39 2015 +0200
Presence: Simplified signals and signal relays.
If we want to avoid shared_ptr cyclic references, we need to
respect a few rules:
- never bind and have a constant shared_ptr as argument. Especially if
you pass the current object as shared_ptr argument to the binding
method
- only pass objects representing data that actually changed to signals.
lib/engine/presence/cluster-impl.h | 41 ++------------------------------
lib/engine/presence/cluster.h | 18 +++++++-------
lib/engine/presence/heap-impl.h | 6 ++--
lib/engine/presence/presence-core.cpp | 8 +-----
lib/engine/presence/presence-core.h | 15 ------------
5 files changed, 16 insertions(+), 72 deletions(-)
---
diff --git a/lib/engine/presence/cluster-impl.h b/lib/engine/presence/cluster-impl.h
index 211b043..7fc277e 100644
--- a/lib/engine/presence/cluster-impl.h
+++ b/lib/engine/presence/cluster-impl.h
@@ -91,16 +91,6 @@ namespace Ekiga
const_iterator end () const;
DynamicObjectStore<HeapType> heaps;
-
- private:
-
- void common_removal_steps (boost::shared_ptr<HeapType> heap);
-
- void on_presentity_added (PresentityPtr presentity, boost::shared_ptr<HeapType> heap);
-
- void on_presentity_updated (PresentityPtr presentity, boost::shared_ptr<HeapType> heap);
-
- void on_presentity_removed (PresentityPtr presentity, boost::shared_ptr<HeapType> heap);
};
/**
@@ -115,9 +105,9 @@ template<typename HeapType>
Ekiga::ClusterImpl<HeapType>::ClusterImpl ()
{
/* signal forwarding */
- heaps.object_added.connect (boost::ref (heap_added));
- heaps.object_removed.connect (boost::ref (heap_removed));
- heaps.object_updated.connect (boost::ref (heap_updated));
+ heaps.object_added.connect (boost::ref (heap_added), _1);
+ heaps.object_removed.connect (boost::ref (heap_removed), _1);
+ heaps.object_updated.connect (boost::ref (heap_updated), _1);
}
template<typename HeapType>
@@ -136,11 +126,7 @@ template<typename HeapType>
void
Ekiga::ClusterImpl<HeapType>::add_heap (boost::shared_ptr<HeapType> heap)
{
- heaps.add_connection (heap, heap->presentity_added.connect (boost::bind
(&ClusterImpl::on_presentity_added, this, _1, heap)));
- heaps.add_connection (heap, heap->presentity_updated.connect (boost::bind
(&ClusterImpl::on_presentity_updated, this, _1, heap)));
- heaps.add_connection (heap, heap->presentity_removed.connect (boost::bind
(&ClusterImpl::on_presentity_removed, this, _1, heap)));
heaps.add_connection (heap, heap->questions.connect (boost::ref (questions)));
-
heaps.add_object (heap);
}
@@ -152,27 +138,6 @@ Ekiga::ClusterImpl<HeapType>::remove_heap (boost::shared_ptr<HeapType> heap)
}
template<typename HeapType>
-void
-Ekiga::ClusterImpl<HeapType>::on_presentity_added (PresentityPtr presentity, boost::shared_ptr<HeapType>
heap)
-{
- presentity_added (heap, presentity);
-}
-
-template<typename HeapType>
-void
-Ekiga::ClusterImpl<HeapType>::on_presentity_updated (PresentityPtr presentity, boost::shared_ptr<HeapType>
heap)
-{
- presentity_updated (heap, presentity);
-}
-
-template<typename HeapType>
-void
-Ekiga::ClusterImpl<HeapType>::on_presentity_removed (PresentityPtr presentity, boost::shared_ptr<HeapType>
heap)
-{
- presentity_removed (heap, presentity);
-}
-
-template<typename HeapType>
typename Ekiga::ClusterImpl<HeapType>::iterator
Ekiga::ClusterImpl<HeapType>::begin ()
{
diff --git a/lib/engine/presence/cluster.h b/lib/engine/presence/cluster.h
index 9aa3f0a..c6004b9 100644
--- a/lib/engine/presence/cluster.h
+++ b/lib/engine/presence/cluster.h
@@ -61,20 +61,20 @@ namespace Ekiga
*/
virtual void visit_heaps (boost::function1<bool, HeapPtr >) const = 0;
- /** Those signals are emitted whenever a new Heap is added or removed
- * from the Cluster.
- * @param The Heap in question.
+
+ /** This signal is emitted when a Heap has been added to the Source.
*/
boost::signals2::signal<void(HeapPtr)> heap_added;
- boost::signals2::signal<void(HeapPtr)> heap_removed;
- /** Those signals are forwarded from the given Heap
- * @param The Heap in question.
+
+ /** This signal is emitted when a Heap has been updated in the Source.
*/
boost::signals2::signal<void(HeapPtr)> heap_updated;
- boost::signals2::signal<void(HeapPtr , PresentityPtr )> presentity_added;
- boost::signals2::signal<void(HeapPtr , PresentityPtr )> presentity_updated;
- boost::signals2::signal<void(HeapPtr , PresentityPtr )> presentity_removed;
+
+
+ /** This signal is emitted when a Heap has been removed in the Source.
+ */
+ boost::signals2::signal<void(HeapPtr)> heap_removed;
};
typedef boost::shared_ptr<Cluster> ClusterPtr;
diff --git a/lib/engine/presence/heap-impl.h b/lib/engine/presence/heap-impl.h
index f187943..e0a2041 100644
--- a/lib/engine/presence/heap-impl.h
+++ b/lib/engine/presence/heap-impl.h
@@ -105,9 +105,9 @@ template<typename PresentityType>
Ekiga::HeapImpl<PresentityType>::HeapImpl ()
{
/* this is signal forwarding */
- presentities.object_added.connect (boost::ref (presentity_added));
- presentities.object_removed.connect (boost::ref (presentity_removed));
- presentities.object_updated.connect (boost::ref (presentity_updated));
+ presentities.object_added.connect (boost::ref (presentity_added), _1);
+ presentities.object_removed.connect (boost::ref (presentity_removed), _1);
+ presentities.object_updated.connect (boost::ref (presentity_updated), _1);
}
diff --git a/lib/engine/presence/presence-core.cpp b/lib/engine/presence/presence-core.cpp
index 8ae32bf..34bf367 100644
--- a/lib/engine/presence/presence-core.cpp
+++ b/lib/engine/presence/presence-core.cpp
@@ -38,7 +38,7 @@
#include "personal-details.h"
-Ekiga::PresenceCore::PresenceCore ( boost::shared_ptr<Ekiga::PersonalDetails> _details): details(_details)
+Ekiga::PresenceCore::PresenceCore (boost::shared_ptr<Ekiga::PersonalDetails> _details): details(_details)
{
conns.add (details->updated.connect(boost::bind (&Ekiga::PresenceCore::publish, this)));
}
@@ -48,12 +48,6 @@ Ekiga::PresenceCore::add_cluster (ClusterPtr cluster)
{
clusters.insert (cluster);
cluster_added (cluster);
- conns.add (cluster->heap_added.connect (boost::bind (boost::ref (heap_added), _1)));
- conns.add (cluster->heap_updated.connect (boost::bind (boost::ref (heap_updated), _1)));
- conns.add (cluster->heap_removed.connect (boost::bind (boost::ref (heap_removed), _1)));
- conns.add (cluster->presentity_added.connect (boost::bind (boost::ref (presentity_added), _1, _2)));
- conns.add (cluster->presentity_updated.connect (boost::bind (boost::ref (presentity_updated), _1, _2)));
- conns.add (cluster->presentity_removed.connect (boost::bind (boost::ref (presentity_removed), _1, _2)));
cluster->questions.connect (boost::ref (questions));
}
diff --git a/lib/engine/presence/presence-core.h b/lib/engine/presence/presence-core.h
index d3b5bfd..8b1d0e2 100644
--- a/lib/engine/presence/presence-core.h
+++ b/lib/engine/presence/presence-core.h
@@ -169,21 +169,6 @@ namespace Ekiga
*/
boost::signals2::signal<void(ClusterPtr)> cluster_removed;
- /** Those signals are forwarding the heap_added, heap_updated
- * and heap_removed from the given Cluster.
- *
- */
- boost::signals2::signal<void(HeapPtr)> heap_added;
- boost::signals2::signal<void(HeapPtr)> heap_updated;
- boost::signals2::signal<void(HeapPtr)> heap_removed;
-
- /** Those signals are forwarding the presentity_added, presentity_updated
- * and presentity_removed from the given Heap of the given Cluster.
- */
- boost::signals2::signal<void(HeapPtr, PresentityPtr)> presentity_added;
- boost::signals2::signal<void(HeapPtr, PresentityPtr)> presentity_updated;
- boost::signals2::signal<void(HeapPtr, PresentityPtr)> presentity_removed;
-
private:
std::set<ClusterPtr > clusters;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]