DirectConnection / QueuedConnection : Parallel Execution Problem
-
Hello,
I am looking for a slot, under Qt, that can not be run multiple times in parallel, even if simultaneous reception of signals that could trigger it. I understood that the QueuedConnection parameter prevented multiple executions of the same slot, forcing the end of the execution of the slot before launching a new instance corresponding to a new signal then stored temporarily in an event queue . But even with QueuedConnection, I get parallel executions of the slot, yet in one thread.
server = new QTcpServer(this); server->listen(QHostAddress::Any, 50885); connect(server, SIGNAL(newConnection()), this, SLOT(new_connection()), Qt::BlockingQueuedConnection);
When I use BlockingQueuedConnection, I get the following message, and the signal does not call the slot:
Qt: Dead lock detected while activating a BlockingQueuedConnection: Sender is QTcpServer(0x2392018), receiver is Machine(0x23336a8)
Do you have any idea how to force linear, non-simultaneous executions? And if you have elements of understanding that allow me to better understand the operation of the last parameter of connect (), it is willingly :)
Thank you beforehand
-
Hi and welcome to devnet,
What exactly do you want to achieve with your application ?
The connection types are all explained in the documentation here.
-
@After
For the reason whyQt::BlockingQueuedConnection
does not work for you and gives you the error message, from the manual page @SGaist references:Same as Qt::QueuedConnection, except that the signalling thread blocks until the slot returns. This connection must not be used if the receiver lives in the signalling thread, or else the application will deadlock.
It's for use across different threads for emitter/receiver, only.