TQObject 'signal' from TThread cause GUI carsh

Dear you,

My ROOT:ROOT 5.34/00 (branches/v5-34-00-patches@44569, Jun 05 2012, 15:31:56 on win32)
Work with VC9.0

I use TQObject ‘signal/slot’ method in a ‘TThread’ to ‘Emit’ a signal, and the accepter is a class inherit from TGMainFrame. I find that if the ‘slot’ do something with the GUI window, the program will crash. However if the ‘signal’ was not from ‘TThread’ it works ok.

I have prepared a minimal example reproducing the problem. The example is prepared with VC9.0. You can find that if you click the “Start Thread” the program will crash.

In file TTestFrame.cpp’:

void TTestFrame::ShowText(const char *text)
{
	ClearTextView();
	fviewText->AddLineFast(text);
	fviewText->Update();                   //program will crash on this line
	fviewText->ShowBottom();           //and this line
}

If I ‘connect’ the signal to a ‘slot’ which do nothing to the GUI Frame (as showed following)
In file TTestTask.cpp’:

void TTestTask::CoutBroadMessageSignal()
{
	cout << "Message Signal" << endl;
}

the program will work well.

I have tested that this example works well under [color=#FF0000]Linux with gcc [/color]version 4.4.4 20100503 (Red Hat 4.4.4-2) (GCC) and ROOT 5.27/02 (trunk@33229, Apr 27 2010, 11:38:29 on linux) and ROOT 5.34/00

What should I do to solve this problem.
Any help or advice is appreciated.
Han
guicrash.rar (17.5 KB)

No one knows how to solve this problem?
Han

Hi Han,

The issue on Windows is that the gVirtualX calls should come from the main (GUI) thread. Using a timer should be sufficient to solve the problem. Simply try this way:[code]void TTestFrame::ShowText(const char *text)
{
ClearTextView();
fviewText->AddLineFast(text);
TTimer::SingleShot(10, “TTestFrame”, this, “UpdateTextView()”);
}

void TTestFrame::UpdateTextView()
{
fviewText->Update();
fviewText->ShowBottom();
}
[/code]
Cheers, Bertrand.

Dear Bertrand,

Thank you very much for your help!

Best wishes,
Han