Path: utzoo!attcan!uunet!husc6!mailrus!ames!pasteur!ucbvax!POSTGRES.BERKELEY.EDU!dillon From: dillon@POSTGRES.BERKELEY.EDU (Matt Dillon) Newsgroups: comp.sys.amiga.tech Subject: Re: VANILLAKEYS and various other things Message-ID: <8811230518.AA05776@postgres.Berkeley.EDU> Date: 23 Nov 88 05:18:37 GMT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 64 :Hmm, people seem to have mistaken what was going on. I will explain. :I have a program which is a graphics program. It basically does :calculations etc, for each pixel. After writing that pixel :I do a GetMsg(). This is for the closewindow gadget. If this :has happened, I return from the subroutine which is doing the :calculating. I then will do a Wait() for further action. : :It is this wait that returns immediatly. I then do a GetMsg() :to see what happened, and GetMsg() returns NULL. the :only thing I can assume is the signal is not cleared. Ohhh.. sorry. Easy to explain: The GetMsg() call in itself does NOT clear the signal bit. Thus, when intuition sends the CLOSEWINDOW IDCMP, this both sets the signal and places the message on the UserPort. You then GetMsg() it (which does not clear the signal). You then Wait() on the signal, which returns immediately because the signal was set. A further GetMsg() results in NULL (unless intuition sent you a second message). The Wait() call clears the signal. Now, you must ReplyMsg() ANY message you have successfully retrieved via GetMsg(). main() { short notdone = 1; .... while (notdone) { WriteThePixel() if (imess = GetMsg(UserPort)) { long class = imess->Class; ReplyMsg(imess); if (class == CLOSEWINDOW) notdone = 0; } } CloseWindow(Win); } Of course, once you finish rendering and are 'Idle' waiting for the window to be closed you would put a Wait(1 << UserPort->mp_SigBit) in the loop: while (notdone) { Wait(1 << UserPort->mp_SigBit); /* OR WaitPort(UserPort) */ while (imess = GetMsg(UserPort)) { /* process the message */ ReplyMsg(imess); /* you must reply it */ } } Where, due to timing, there are bound to be cases where the Wait() returns and the GetMsg() comes back NULL the first time, but the way the loop is setup it doesn't matter. The most common mistake is to break out of the loop when you get the CLOSEWINDOW IDCMP and forgetting to ReplyMsg() it. By using a 'notdone' variable you can avoid the mistake, because then all you would do when you get the CLOSEWINDOW is clear the variable and continue normally (ReplyMsg()ing it and handling any further messages). -Matt