Hi!
I have an application with a GUI where modules communicate via signals. There is a 'producer module' which produces data and finally a 'painter module' which draws the data to a canvas. Whenever new data is available, the producer emits a signal and the painter which is connected to the producer then redraws the canvas. The producer itself is connected to a button and it produces new data at every click.
So far, so good. I now want to have a thread clicking the button for me. I created a thread routine to which I hand over a pointer to the producer and the thread then calls the same function as the button on a regular basis. This works as long as I do not draw to a canvas, or more exactly as long as I do not update the canvas within the thread.
I have attached a small stripped down example of my application to illustrate my problem. The example can be run either as a standalone application (build by 'make') or in CINT by calling 'root Test.C' in the shell.
When you run the example a ROOT canvas and a small window with two buttons and a checkbox opens. When you click the 'Click Me!' button, it triggers the producer to emit a signal to the painter which then draws a number to the canvas. At the same time the number is also written in the shell. When unchecking the check box, the canvas is no longer updated. When you click the 'Click Me!' button now, you see the current counter value when you directly click on the canvas.
If you press the 'Start Thread' button, a thread is created with calls the same method in the producer class as the 'Click Me' button every second. You can see the counter incrementing in the shell. When you click on the canvas as soon as a new counter value is presented in the shell, the same number appears also there. But if you set the checkbox status back to true the application suddenly freezes.
I tried to follow the code execution with ddd but I only found that the execution path seems to circle between classes like TStorage or TMutex... However I could not identify what went wrong. :(
Can somebody give me a hint how to make the example work?
Thanks a lot!
Thomas Lauf
ps: I tested the example on ROOT 5.36 and 5.30 with the same unfortunate result, both times on a Linux machine.
This archive was generated by hypermail 2.2.0 : Mon Aug 22 2011 - 17:50:02 CEST