Quantcast
Channel: Installation and Deployment
Viewing all articles
Browse latest Browse all 22112

How to prevent slot re-entrancy

$
0
0
Hello, So, I’m developing a system that allows an external computer (lets say a microcontroller) send commands to a desktop application via a serial interface. My idea is to have one object that receives the sent bytes and it builds up remote function call packets from the received bytes and then signals the slots of other objects that the remote function calls were meant for. However, this is my problem. Let’s say I have a GUI object that has a bunch of remote function call slots. They are just normal slots except that they are not meant to be executed by the user using the graphical user interface. As long as each of the slots for this GUI object do not return to the event loop while executing then their is no re-entrancy into the object and everything is good. However, a few of the slots I have in the object can take a while to execute. In these functions, to prevent the GUI from looking up I use an event loop. However, this also means that that re-entrancy can occur if a slot for this object is called again. So, my problem is this… how do I make sure that only one slot in a object may be called at a time? What I really want is a blockSlots() function like the block signals function. But, qt doesn’t have this. This problem is something I’ve run into multiple times now working with Qt and I don’t know how to solve it. Maybe I’m structuring my code badly, and if so, how could I change my structure to fix this? I can’t use a thread to solve this problem because this is a GUI object. I want to use a thread to run the object that dispatches the remote function calls from bytes received from the serial port.

Viewing all articles
Browse latest Browse all 22112

Trending Articles