You are not logged in.

1

Monday, July 23rd 2012, 1:54pm

errors while painting and using threads

Hi,

I have a method which paints something. I know that painting is only possible in the main thread. That's why I tried this:

I use a thread which was started in the main thread from the class subwindow_fitter. After the thread is ready it calls the method subwindow_fitter::send_signal_calculation_finished () which sends a signal signal_calculation_finished ().
To start painting I connect this with
connect(this, SIGNAL(signal_calculation_finished(bool)), this, SLOT(calculation_finished(bool)));

Unfortunately I get some error messages like

Quoted

X Error: BadRequest (invalid request code or no such operation) 1
Extension: 255 (Uknown extension)
Minor opcode: 0 (Unknown request)
Resource id: 0x40000f9
X Error: BadColor (invalid Colormap parameter) 12
Major opcode: 88 (X_FreeColors)
Resource id: 0x50694
...

It seems like the thread wanted to paint something but I do not why this should be the case.

I tried something else:
Now the thread calls a method from another object:
calculator::emitsignal_calculation_finished ();
and connect this like in the first case:

connect(m_Calculator, SIGNAL(calculation_finished()), this, SLOT(calculation_finished()));

And everything works well!

Do you have any idea why I get these errors on the first case? Is it because the thread was created from the same object that sends and receive the signal and that starts to paint?

Thanks for your help!