PDA

View Full Version : Can a QGraphicsScene's mousePressEvent & mouseReleaseEvent be running simultaneously?



blooglet
12th February 2011, 21:39
I have a question about thread safety. Is it possible that at some point a QGraphicsScene's mousePressEvent and mouseReleaseEvent functions could be in execution simultaneously? That would have serious implications for the way I write my code. I haven't created any additional threads myself, but since Qt programs always consist of multiple threads it might be possible theoretically that both events are being handled at the same time.

wysota
13th February 2011, 00:10
I have a question about thread safety. Is it possible that at some point a QGraphicsScene's mousePressEvent and mouseReleaseEvent functions could be in execution simultaneously?
No, there is no such possibility unless you call the one method yourself from implementation of the other.


but since Qt programs always consist of multiple threads
That's not true, who told you that?

blooglet
13th February 2011, 09:42
That's not true, who told you that?
In Qt Creator's debugger, I can see how many threads are associated with the program. On several occasions, I saw that about 4 threads were running even though I hadn't used QThreads anywhere in my code. I sort of assumed that Qt programs always created multiple threads.

wysota
13th February 2011, 11:06
The word 'always' has a very specific meaning that is much different from the word 'sometimes'. It is almost important what the threads do.