PDA

View Full Version : QDialog::exec : Recursive call detected.



node_ex
29th June 2008, 12:48
Hi,

I am using Qt4. My application has a main thread and one more thread running continuously to read data from file. This thread invokes postEvent to particular object. After receiving the the event in customEvent method of respective object, it calls QDialog::Exec function to display dialog. when this Exec is called again through thread i am using QWidget::close() fn to QDialog object before calling QDialog::Exec method. After this QDialog::exec() fn executed. I am getting

QDialog::exec() :recursive call detected.

Why close function is unable to stop the event loop. How to handle this issue?

Regards,
node_ex.

jpn
29th June 2008, 13:06
You must not call close(), exec() or any other GUI function from a worker thread. QWidget and all its subclasses are not reentrant. They can only be used from the main thread.

node_ex
29th June 2008, 17:17
Hi jpn,

I am calling postEvent in thread, qt handle this event. QApplication object will be in main thread. So the customEvent method also runs in main thread. QDialog::Exec and close functions are called by customEvent method.

Regards,
node_ex.

jpn
29th June 2008, 17:40
Well, basically you could try calling QDialog::done() to make the dialog finish its event loop to be able to start a new one with QDialog::exec(). But is that what you want, really? The dialog would close and popup now and then...

I would rather implement necessary logic to prevent multiple calls to QDialog::exec(). You could first try QWidget::isVisible() and if that doesn't work, then store the information as a member variable or something.

node_ex
29th June 2008, 17:50
I want to suspend the main thread using exec function. Is there any other logic to suspend main thread with out using while loop.

Regards,
node_ex.