diff --git a/src/qamqpchannelhash.cpp b/src/qamqpchannelhash.cpp index 98883ab..9fba2d6 100644 --- a/src/qamqpchannelhash.cpp +++ b/src/qamqpchannelhash.cpp @@ -62,17 +62,16 @@ void QAmqpChannelHash::put(QAmqpQueue* queue) } /*! -* Handle destruction of a channel. Retrieve its current name and -* remove it from the list, otherwise do a full garbage collection -* run. +* Handle destruction of a channel. Do a full garbage collection run. */ -void QAmqpChannelHash::channelDestroyed() +void QAmqpChannelHash::channelDestroyed(QObject* object) { - QAmqpChannel* ch = static_cast(sender()); - if (!channels.contains(ch->name())) - return; - if (channels[ch->name()] == ch) - channels.remove(ch->name()); + QList names(channels.keys()); + QList::iterator it; + for (it = names.begin(); it != names.end(); it++) { + if (channels.value(*it) == object) + channels.remove(*it); + } } /*! @@ -91,8 +90,8 @@ void QAmqpChannelHash::queueDeclared() */ void QAmqpChannelHash::put(const QString& name, QAmqpChannel* channel) { - connect(channel, SIGNAL(destroyed()), - this, SLOT(channelDestroyed())); + connect(channel, SIGNAL(destroyed(QObject*)), + this, SLOT(channelDestroyed(QObject*))); channels[name] = channel; } diff --git a/src/qamqpchannelhash_p.h b/src/qamqpchannelhash_p.h index 6533c10..c438022 100644 --- a/src/qamqpchannelhash_p.h +++ b/src/qamqpchannelhash_p.h @@ -62,11 +62,9 @@ public: private Q_SLOTS: /*! - * Handle destruction of a channel. Retrieve its current name and - * remove it from the list, otherwise do a full garbage collection - * run. + * Handle destruction of a channel. Do a full garbage collection run. */ - void channelDestroyed(); + void channelDestroyed(QObject* object); /*! * Handle a queue that has just been declared and given a new name. The