Problem with Qt::QueuedConnection, signal delivered after disconnect
Posted
by lutku
on Stack Overflow
See other posts from Stack Overflow
or by lutku
Published on 2010-03-28T08:50:54Z
Indexed on
2010/03/28
8:53 UTC
Read the original article
Hit count: 374
qt
Hi,
I just discovered interesting behavior of queued connection in Qt 4.6:
First queued connection is made:
connect(someSender, SIGNAL(completed()), this, SLOT(handleCompletion()), Qt::QueuedConnection)
Then someSender sends the signal:
emit completed()
Before receiving signal (as it is in queue), I disconnect from the signal:
disconnect(someSender, SIGNAL(completed()), this, SLOT(handleCompletion())
Still, handleCompletion slot is invoked at next eventloop iteration. I can prevent this from happening by using someSender->blockSignals(true) at correct point, but it feels awful not to mention having some boolean flag to disable slot's functionality.
Especially, I feel amazed that this behavior is not mentioned in Qt documentation (at least I haven't found).
Finally the question: any sensible way to avoid this from happening?
© Stack Overflow or respective owner