QAmqpChannelHash: Tweak channelDestroyed.
- DON'T rely on sender() - DON'T expect to be able to cast the QObject to a QAmqpChannel and have name() work. This isn't as efficient as I'd like, but it doesn't crash either.
This commit is contained in:
parent
ae4f1b336e
commit
31f90a17a0
|
|
@ -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<QAmqpChannel*>(sender());
|
||||
if (!channels.contains(ch->name()))
|
||||
return;
|
||||
if (channels[ch->name()] == ch)
|
||||
channels.remove(ch->name());
|
||||
QList<QString> names(channels.keys());
|
||||
QList<QString>::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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue