Boost logo

Boost Users :

Subject: [Boost-users] Connecting signals2::signal to another signals2::signal: trackable?
From: Chris Stankevitz (chrisstankevitz_at_[hidden])
Date: 2012-08-02 21:35:23


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


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