3 Aug
2012
3 Aug
'12
1:35 a.m.
class A { boost::signals2::signal<void()> Signal; } class B { boost::signals2::signal<void()> Signal; } boost::shared_ptr<A> pA = boost::make_shared<A>(); boost::shared_ptr<B> pB = boost::make_shared<B>(); === Q1: Is it possible to connect A's signal to B? A1: Yes: void f() { pA->Signal.connect(pB->Signal); pA->Signal(); } === Q2: Will I get a crash if pB is subsequently released? A2: Yes void f() { pA->Signal.connect(pB->Signal); pB.reset(); pA->Signal(); // crash! } === Q3: Is it possible to use signals2::signal::slot_type::track to avoid the crash? A3: [I do not know the answer, please help me here] === Thank you, Chris