Solved Disconnecting a BlockingQueuedConnection
-
If a signal connected using Qt::BlockingQueuedConnection is emitted and then disconnected before the receiving slot returns, what happens? Does the sender wait to disconnect until after the slot returns?
-
@KevNull I don't think anything special will happen. The slot is already being executed and you simply disconnect, so the slot will not be called again if the signal is emitted. disconnect() does not have any influence on the slot. Also disconnect() can only be called from another thread while the slot is still being executed as the connection is blocking. That means, the sender can only call disconnect if the slot has finished.
-
That makes sense. So I guess both threads remain busy and further calls to emit signal() will simply not have an effect.
-
@KevNull Well, further calls to emit signal will be queued and executed one after the other.
-
@jsulm said in Disconnecting a BlockingQueuedConnection:
That means, the sender can only call disconnect if the slot has finished.
This doesn't imply a third thread couldn't call
disconnect
, but that should not be a problem either, asdisconnect()
is thread-safe. -
@kshegunov "Also disconnect() can only be called from another thread while the slot is still being executed as the connection is blocking." :-)