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

Thiago Macieira thiago.macieira at intel.com
Sat Mar 10 16:59:14 CET 2012

On sábado, 10 de março de 2012 17.37.30, Nikos Chantziaras wrote:
>    QMessageBox* msgBox = new QMessageBox(...)
>    msgBox.exec();
>    qDebug() << "After";

This doesn't compile.

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

It's normal. The object hasn't been deleted, so the windowing system's window 
is still present. Whether it will be hidden soon, there's no way to tell.

> 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);
>    qApp->sendPostedEvents();
>    qApp->processEvents(QEventLoop::WaitForMoreEvents
>                        | QEventLoop::AllEvents);
>    qApp->sendPostedEvents();
> However, I don't see how this would cause the strange behavior with
> dialogs, since they have their own, local event loops.

We don't know. Usually, the problem is not where you expect it to be. In this 
case, the problem is definitely nowhere in the code you posted, so we can't 
help you without more code.

Please provide us a compileable testcase.

> 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

Alter it by removing everything and anything that doesn't cause the behaviour 
to change. Remove everything until you're left with the most minimal code that 
still shows the problem. That's the testcase I'm asking for.

Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
     Intel Sweden AB - Registration Number: 556189-6027
     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120310/ee7827b1/attachment.sig>

More information about the Interest mailing list