[Interest] Strange problem where exec() of dialogs returns immediately

Nikos Chantziaras realnc at gmail.com
Sat Mar 10 16:37:30 CET 2012

I have a very strange problem, where calls to functions like 
QMessageBox::question() or QMessageBox::exec() or 
FileDialog::getOpenFileName() (and other cases where dialogs create 
their own, local event loops) will return immediately without waiting 
for the user to do any input first.

Even weirder, in the case of QMessageBox::question() and 
QMessageBox::exec(), even though the call returns immediately, the 
dialog is still open and responsive, waiting for the user to make a 
choice.  For example:

   QMessageBox* msgBox = new QMessageBox(...)
   qDebug() << "After";

The above code will print "After" on stderr even though the message box 
is still visible and none of the buttons have been clicked.

One unusual thing about the application in question is that it "blocks" 
all the time (it has to) and moves things along with:

   qApp->sendPostedEvents(0, QEvent::DeferredDelete);
                       | QEventLoop::AllEvents);

However, I don't see how this would cause the strange behavior with 
dialogs, since they have their own, local event loops.

Can anyone think of anything that could be causing this?  I've been 
altering code all day long in order to track this down, and I'm at a 
point where shooting myself in the head starts to sound attractive :-P

More information about the Interest mailing list