QCopChannel::QCopChannel( const QCString& channel, QObject* parent, const char* name ) : QObject( parent, name ) { d = new QCopChannelPrivate; d->channel = channel; if ( !qt_fbdpy ) { qFatal( "QCopChannel: Must construct a QApplication " "before QCopChannel" ); return; } if ( !qcopClientMap ) qcopClientMap = new QCopClientMap; // do we need a new channel list ? QCopClientMap::Iterator it = qcopClientMap->find( channel ); if ( it != qcopClientMap->end() ) { it.data().append( this ); return; } it = qcopClientMap->insert( channel, QList<QCopChannel>() ); it.data().append( this ); // inform server about this channel qt_fbdpy->registerChannel( channel ); }
QCopChannel::~QCopChannel() { QCopClientMap::Iterator it = qcopClientMap->find( d->channel ); ASSERT( it != qcopClientMap->end() ); it.data().removeRef( this ); // still any clients connected locally ? if ( it.data().isEmpty() ) { QByteArray data; QDataStream s( data, IO_WriteOnly ); s << d->channel; if ( qt_fbdpy ) send( "", "detach()", data ); qcopClientMap->remove( d->channel ); } delete d; }