I am writing a standalone applilcation for acq with GUI. The data are collected, displayed and sucessfully writen to file. This works fine on one thread. I want to use a second thread or maybe even more (since we all now have multicore processors) to do online analysis. The application works fine until I do not move a mouse. Sometime crashes immediately, sometime after while but always does.
I wrote a simple version where TGMainFrame has TGEmbeddedCanvas and two buttons (update, stop). When I press button update the new thread is created, generate some data and using SetPoint update TGraph.
By reading the forum I found similar issues:
[url]TQObject 'signal' from TThread cause GUI carsh
[url]Real-time analasys of data stream
but I still cannot solve my problem. Can anybody help me? Maybe I am doing somthing simply stupid? Or maybe my application needs to be redisigned?
threadGUI.tar.gz (2.35 KB)
Do you have a trace back ?
I see the crash in different places.
I tried various things … nothing worked for the time being …
Why do you use simple integer variable to check, if thread should stop?
More: how do you think, is it possible, that while you setting graph points in a second thread, the main thread is trying to do something with objects in a canvas?
Look into SetPoint - it calls delete fHistogram, are you sure nobody else is trying to use this fHistogram data member in a second thread?
And even more: does the ROOT’s documentation say that any of histograms are thread safe?
Looking a bit more, we do not think this can work with TGraph and SetPoint.
In SetPoint fHistogram is deleted. Then when you pick the graph on the window
GetHistogram() is called, so if a SetPoint has been called in the other tread it may well
be that the histogram does not exist anymore or point to a different one form the one
It seems that your program can worked only if you disable all the interactions in the graphics window while it is running.
Note that doing gSystem->Sleep(100);
helps a bit … but there no garantie it will never crash