
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 13 October 2008 08:25 am, Sergey Kishchenko wrote:
boost::shared_ptr
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: "<
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-----