Hi,
I am experiencing some strange things when trying to disconnect some signals. I will try to explain through a simpler example since my real application is a bit more messy.
I have an object of a class A, A1, to which I connect two objects of class B, B1 and B2. The B objects are ment to update each time A1 changes and be deleted if A1 is deleted. It is possible that B1 is deleted regardless of A1 and B2.
In class B’s ctor I have:
B::B(A* ptr) : a(ptr){
a->Connect("Altered()","B",this,"Update()");
a->Connect("Destroyed()","B",this,"KillMe()");
}
and in the first attempt of a dtor I have:
B::~B(){
a->Disconnect(0,this,0);
}
However of some reason this stop the Destroyed() signal to reach B2 if A1 is deleted. My conclusion is that B1’s dtor in some way also disconnects B2 from A1. Since each B is only connected to one A i tried an alternative dtor that disconnect all signals from objects of class A:
B::~B{
TQObject::Disconnect("A",0,this,0);
}
This should be equivalent in my case to the previous dtor but now both B:s are deleted if A1 is. However now the “Altered()” signal is not disconnected leading to the situation that if B1 is deleted and A1 is altered afterwards, I get a segfault. My last dtor that at least does not cause any segfaults looks like:
B::~B(){
a->Disconnect("Altered()",this,"Update()");
TQObject::Disconnect("A","Destroyed()",this,"killMe()");
}
any other combination of the commands I have tried leads to segfaults in some situation.
I am very puzzled by this behaviour. Have I misunderstood how signals are supposed to be handled or is there a bug lurking around somewhere? My ROOT-version is 5.27/04.
Grateful for any help.