[Singals]problem about add a new connection in slot callback

Hi! I'm afraid i can't discribe the problem very well, so please see the code: #include <boost/signal.hpp> #include <iostream> using namespace std; typedef boost::signal<void ()> signal_t; typedef boost::signals::connection connection_t; signal_t g_signal; void test_b() { cout << "b" << endl; } void test_a() { cout << "a" << endl; g_signal.connect(test_b); } int _tmain(int argc, _TCHAR* argv[]) { connection_t t = g_signal.connect(test_a); g_signal(); t.disconnect(); g_signal(); return 0; } int the function test_a , I perfer call test_b next signal that mean output is "a b" but test_b is called immediately and the output is "a b b" how can I solve the problem? mos.

On Friday 07 August 2009, mos wrote:
int the function test_a , I perfer call test_b next signal that mean output is "a b" but test_b is called immediately and the output is "a b b"
how can I solve the problem?
You could use Boost.Signals2. It has slightly different behavior than the original Boost.Signals when a slot is connected during invocation. The newly connected slot is not seen until subsequent invocations, which seems to be the behavior you want.
participants (2)
-
Frank Mori Hess
-
mos