|
Boost Users : |
Subject: Re: [Boost-users] Using boost.signals with boost.bind
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2008-10-14 09:37:23
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Monday 13 October 2008 08:25 am, Sergey Kishchenko wrote:
> boost::shared_ptr<signal_type> apSig(new signal_type());
> apSig->connect(binded_func);
> (*apSig)();
>
> apSig.reset(new signal_type());
> boost::signals::connection con = apSig->connect(binded_func);
> std::cout<<"Connected: "<<con.connected()<<" Blocked:
> "<<con.blocked()<<"\n"; }
>
>
> Program output:
>
> Func::operator(42)
> Connected: 0 Blocked: 1
>
> Ie, if i create new signal and then try to connect to the same slot, it
> fails. If I use not boost::bind object but only boost::function as slot,
> all works ok. I can not understand, why? I used Boost 1.34.1, gcc 4.1.2
It looks like a bug to me. In boost.signals, the slot has a shared_ptr to its
signal/slot connection, which I think it uses for automatic connection
management. So it looks like it was coded under the assumption a slot object
(or any of its copies) would not be re-used with more than 1 signal. The
slot is probably (permanently) auto-disconnecting when the first signal it
was connected to is destroyed. The signals2 lib, which might get reviewed
soon if there are enough reviewers, doesn't show this problem.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFI9KCX5vihyNWuA4URAi7uAJ9rwpPp00P/bs03ayUHPIjW3mvtfwCgvCwn
7RqIthZ9NIY6Dc39r7fOJJk=
=UTWd
-----END PGP SIGNATURE-----
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net