SignallingInterface* SignallingReceiver::attach(SignallingInterface* iface) { Lock lock(m_ifaceMutex); if (m_interface == iface) return 0; SignallingInterface* tmp = m_interface; m_interface = iface; lock.drop(); if (tmp) { if (tmp->receiver() == this) { Debug(this,DebugAll,"Detaching interface (%p,'%s') [%p]", tmp,tmp->toString().safe(),this); tmp->attach(0); } else { Debug(this,DebugNote,"Interface (%p,'%s') was not attached to us [%p]", tmp,tmp->toString().safe(),this); tmp = 0; } } if (!iface) return tmp; Debug(this,DebugAll,"Attached interface (%p,'%s') [%p]", iface,iface->toString().safe(),this); insert(iface); iface->attach(this); return tmp; }
void SignallingReceiver::attach(SignallingInterface* iface) { Lock lock(m_ifaceMutex); if (m_interface == iface) return; SignallingInterface* tmp = m_interface; m_interface = iface; lock.drop(); if (tmp) { const char* name = 0; if (engine() && engine()->find(tmp)) { name = tmp->toString().safe(); tmp->attach(0); } Debug(this,DebugAll,"Detached interface (%p,'%s') [%p]",tmp,name,this); } if (!iface) return; Debug(this,DebugAll,"Attached interface (%p,'%s') [%p]", iface,iface->toString().safe(),this); insert(iface); iface->attach(this); }