PDA

View Full Version : Access to signal queue?



sandor
25th June 2011, 20:00
Hello There,

I have a bit of a problem with the signal queue and do hope that someone might give me a hint. There are two threads communicating with each other by emitting signals - works for the other on an existing QTcpSocket connection (it is an API implementation) and signals the other thread when sending and receiving of data was done - the decoded data is available.
The problem is that signals look to be lost after a while, so signals emitted are never received in the thread handling the API via the QTcpSocket. I am looking for a way to debug it - I would like to see why the emitted signal does not arrive. It looks to be random how many times the emitted signal is actually received: sometime only 3x, sometimes much more before it actually gets stuck so emit is done (I see from the log file) but the slot is never triggered - same class, same thread, same instance does it many times before.

Thanks,
Sandor

wysota
25th June 2011, 23:05
Make sure you handle the socket in the thread it lives in. A common error is to handle a socket in the QThread subclass object which does not live in the thread it controls.

sandor
26th June 2011, 10:00
"Make sure you handle the socket in the thread it lives in. A common error is to handle a socket in the QThread subclass object which does not live in the thread it controls."


Nope, this has nothing to do with it (then Qt would give a bunch of warnings). The issue is that signals emitted are getting lost after a while. I was thinking that the thread locks on some control and put an additional log on locking/unlocking mutexes, and it does not.
So, I just need a way to access the event queue of the thread for debugging so I can see at least if the message is there sitting and waiting, at all.

wysota
26th June 2011, 10:10
Signals can't be getting lost. Especially that they are not queued. Slots are queued but they are not getting lost. Maybe you have a deadlock somewhere in your code.

squidge
26th June 2011, 16:44
I agree with Wysota, signals can't be "getting lost". Either you are not sending them some times or your code blocks and signals are not delivered because of that.

Have you looked at Conan? A "C++ library that provides run-time introspection of object hierarchies, object inheritance, signal/slot connections, and signal emissions."