Results 1 to 5 of 5

Thread: QDialog::exec : Recursive call detected.

  1. #1
    Join Date
    Jun 2008
    Posts
    21
    Thanked 1 Time in 1 Post

    Default QDialog::exec : Recursive call detected.

    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.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QDialog::exec : Recursive call detected.

    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.
    J-P Nurmi

  3. #3
    Join Date
    Jun 2008
    Posts
    21
    Thanked 1 Time in 1 Post

    Default Re: QDialog::exec : Recursive call detected.

    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.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QDialog::exec : Recursive call detected.

    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.
    J-P Nurmi

  5. #5
    Join Date
    Jun 2008
    Posts
    21
    Thanked 1 Time in 1 Post

    Default Re: QDialog::exec : Recursive call detected.

    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.