[ekiga/ds-fix-boost-leaks] Account: Simplified signals and signal relays.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga/ds-fix-boost-leaks] Account: Simplified signals and signal relays.
- Date: Sun, 21 Jun 2015 13:34:49 +0000 (UTC)
commit e3401aa206ea1d04f1687e53be8a61853086fc89
Author: Damien Sandras <dsandras seconix com>
Date: Sat Jun 20 12:17:32 2015 +0200
Account: 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/account/account-core.cpp | 7 -------
lib/engine/account/account-core.h | 33 ++-------------------------------
lib/engine/account/bank-impl.h | 11 +++++------
lib/engine/account/bank.h | 7 +------
4 files changed, 8 insertions(+), 50 deletions(-)
---
diff --git a/lib/engine/account/account-core.cpp b/lib/engine/account/account-core.cpp
index 40f78ba..be903d6 100644
--- a/lib/engine/account/account-core.cpp
+++ b/lib/engine/account/account-core.cpp
@@ -49,13 +49,7 @@ void
Ekiga::AccountCore::add_bank (BankPtr bank)
{
banks.push_back (bank);
-
- bank->account_added.connect (boost::bind (boost::ref (account_added), bank, _1));
- bank->account_removed.connect (boost::bind (boost::ref (account_removed), bank, _1));
- bank->account_updated.connect (boost::bind (boost::ref (account_updated), bank, _1));
-
bank_added (bank);
-
bank->questions.connect (boost::ref (questions));
}
@@ -64,7 +58,6 @@ void
Ekiga::AccountCore::remove_bank (BankPtr bank)
{
bank_removed (bank);
-
banks.remove (bank);
}
diff --git a/lib/engine/account/account-core.h b/lib/engine/account/account-core.h
index 5098caf..e1b4341 100644
--- a/lib/engine/account/account-core.h
+++ b/lib/engine/account/account-core.h
@@ -117,42 +117,13 @@ namespace Ekiga
*/
boost::signals2::signal<void(BankPtr)> bank_removed;
- /** This signal is emitted when a account has been added to one of
- * the banks
- */
- boost::signals2::signal<void(BankPtr, AccountPtr)> account_added;
-
- /** This signal is emitted when a account has been removed from one of
- * the banks
- */
- boost::signals2::signal<void(BankPtr, AccountPtr)> account_removed;
-
- /** This signal is emitted when a account has been updated in one of
- * the banks
- */
- boost::signals2::signal<void(BankPtr, AccountPtr)> account_updated;
-
- private:
-
- std::list<BankPtr> banks;
- typedef std::list<BankPtr>::iterator bank_iterator;
- typedef std::list<BankPtr>::const_iterator bank_const_iterator;
-
-
- /*** Misc ***/
-
- public:
-
- /** This signal is emitted when the AccountCore Service has been
- * updated.
- */
- boost::signals2::signal<void(void)> updated;
-
/** This chain allows the AccountCore to present forms to the user
*/
ChainOfResponsibility<FormRequestPtr> questions;
+ private:
+ std::list<BankPtr> banks;
};
/**
* @}
diff --git a/lib/engine/account/bank-impl.h b/lib/engine/account/bank-impl.h
index db09bf9..6aa7eb4 100644
--- a/lib/engine/account/bank-impl.h
+++ b/lib/engine/account/bank-impl.h
@@ -140,9 +140,9 @@ template<typename AccountType>
Ekiga::BankImpl<AccountType>::BankImpl ()
{
/* this is signal forwarding */
- accounts.object_added.connect (boost::ref (account_added));
- accounts.object_removed.connect (boost::ref (account_removed));
- accounts.object_updated.connect (boost::ref (account_updated));
+ accounts.object_added.connect (boost::ref (account_added), _1);
+ accounts.object_removed.connect (boost::ref (account_removed), _1);
+ accounts.object_updated.connect (boost::ref (account_updated), _1);
}
@@ -196,9 +196,8 @@ template<typename AccountType>
void
Ekiga::BankImpl<AccountType>::add_account (boost::shared_ptr<AccountType> account)
{
- this->add_object (account);
-
account->questions.connect (boost::ref (questions));
+ accounts.add_object (account);
}
@@ -206,7 +205,7 @@ template<typename AccountType>
void
Ekiga::BankImpl<AccountType>::remove_account (boost::shared_ptr<AccountType> account)
{
- this->remove_object (account);
+ accounts.remove_object (account);
}
#endif
diff --git a/lib/engine/account/bank.h b/lib/engine/account/bank.h
index ee8260d..e3c378a 100644
--- a/lib/engine/account/bank.h
+++ b/lib/engine/account/bank.h
@@ -48,6 +48,7 @@ namespace Ekiga
* @{
*/
+ typedef boost::shared_ptr<Bank> BankPtr;
class Bank: public virtual Actor
{
public:
@@ -74,14 +75,8 @@ namespace Ekiga
/** This signal is emitted when a account has been updated.
*/
boost::signals2::signal<void(AccountPtr)> account_updated;
-
- /** This chain allows the BankImpl to present forms to the user
- */
- ChainOfResponsibility<FormRequestPtr> questions;
};
- typedef boost::shared_ptr<Bank> BankPtr;
-
/**
* @}
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]