I have a Boost.Signals2 signal on object 1, and I connect to it on object 2.
If object 2 is destructed the signal will not disconnect which can lead to bad things when its signaled.
To resolve this I keep a scoped_connection
on object 2. The problem now is what if object 1 destructs with the signal and then object 2 destructs.
Will it cause problems? Is there any better way to resolve the general issue? (have a connection from object 1 -> object 2 that will disconnect when on of them destructs).
A code that demonstrates the issue:
auto sig = new signal<void ()>();
auto conn = new scoped_connection(sig.connect(&some_function));
delete sig;
delete conn;
Is this safe?