Connection of signal from separate ( child ) thread to slot of mainwindow ( parent thread - main thread ) problem[SOLVED]
How are you doing?
This is a relatively simple threading problem. I have a main thread where child thread were created and run called:
@@dcc = new DetectClassifyComputation();
cout<<"before starting new thread "<<endl;
cout<<"after starting new thread "<<endl;
cout<<"PREPROCESS 6. "<<endl;
cout<<"END OF PREPROCESS "<<endl;@
where dcc is the instance of the thread class. The signal is defined in the thread class as:
I observe, that MainWindow where I call the run of the thread "hangs" ( "freezes") after some time ( on third or second run of the thread ) with exception code c0000005. That is on Windows 7 and the program fails.
It seems once the slot can't be invoked.
My question is what is the problem? How to fix that?
Thank you in advance in any help with this issue.
It is not quite clear from your explanation what happens... do you see your debug "after starting new thread"?
I just notice one thing, with every thread that I have ever used once it is set to running I never call functions directly on that thread. I always use signal/slot approach. It is little bit dangerous to call functions from other threads directly.
so in theory you would connect another signal/slot from dcc to a slot on "this" (main window?) telling it that it has finished doing whatever it is doing.
Also worth checking / debugging your dcc thread that it is still running (get some printfs or somthing comming out of it to see what it is doing).
I assume you have some code in the Thread::run() function for when it gets the start signal? - what happens then?
Thank you for your try to help. Yep, I connect signal from child thread with slot from parent thread. I've fixed recently the problem, the signal-slot connection should be queued, I've left default thread stack size and the
should not be run. So it works fine now. Closed. Thanks.
no problem, well done, good luck :)