MsgBox problem

Hauke Hildebrandt Hauke.Hildebrandt at iup.uni-heidelberg.de
Wed Nov 29 15:00:11 GMT 2000


Oliver Sbanski wrote:

> Hi,
>
> if I am not allowed to ask the following question on this list, please tell
> me where better to post it. Thanks.
>
> Ok,
> the problem I have is as follows:
> I have a kdevelop project for KDE 1.2, and the following code fraction (which
> is connected to a QTimer) gives me a mysterious problem:
>
> void CLASSNAME::slotDoWhat() {
> ...
> ...
>         for(i=0; i<imax; i++) {
>                 if(finExp.eof()) {
>                         SERR="unexpected end of file!";
>                         KMsgBox::message(0,"caption","SERR",KMsgBox::EXCLAMATION);
>                         slotStopWhat(); // this stops the qtimer as well
>                         return;
>                 }
>                 finExp.getline(s, 200);
>                 ...
>                 ...
>         }
> }
>
> Now, whenever the MessageBox pops up (at eof()), the slotStopWhat() is NOT
> called, instead, the program directly enters the slotDoWhat() again!!!
> Strange enough, if I e.g. put the call to slotStopWhat() as first instruction
> inside the if() statement, the program works as expected.
>
> What did I not understand?
>
> Thanks,
>
> Oli
>
> -
> to unsubscribe from this list send an email to kdevelop-request at kdevelop.org with the following body:
> unsubscribe »your-email-address«

Oli,

is it possible that your slotDoWhat() function is called again by the timer? When your message box
pops up the main event loop of Qt waits for you to close that dialog. In the meantime, the timer calls
the slot again (which
can't be executed at once because the event loop's waiting) and this call is put into the event queue,
being the next to be
executed (before the sloStopWhat() which isn't queued at that time).
I am not an expert on this event loop mechanism, just a guess - anybody else?

Hauke

--
Hauke Hildebrandt
Institut für Umweltphysik
Universität Heidelberg
INF 229
69120 Heidelberg

Tel.: 06221/546318
Fax: 06221/546405

email: hauke.hildebrandt at iup.uni-heidelberg.de




-
to unsubscribe from this list send an email to kdevelop-request at kdevelop.org with the following body:
unsubscribe »your-email-address«



More information about the KDevelop mailing list