🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #2716

Re: CloseWindowSafely

#2716
From: Jim Mackraz
Date: Wed, 13 Dec 1989 20:00
48 lines
1923 bytes
In article <8976@cbmvax.commodore.com> mks@cbmvax.commodore.com (Michael Sinz - CATS) writes:
)>Here is a rough sketch of CloseWindowSafely
)>	CloseWindowSafely(win)
)>	    struct Window *win;
)>	{
)>	    struct MsgPort myport = win->UserPort;
)>	    struct Node *x, *y;
)>	    struct IntuiMsg *t;
)>
)>	    SetIDCMP(win, 0L); /* Inhibit any further msgs for this window*/
)>	    win->UserPort=0;   /* Prevent intuition from freeing my port */
)>
)>	    Forbid(); /* Prevent the Msg system from posting
)>			 messages to "myport" while I fiddle with it */
)>	    for(x=myport->head; x!=endoflist;x=y) {
)>		y=x->next;
)>		t=x;
)>		if(t->window == win) Reply(x); /* Send it back*/
)>	    }
)
)You forgot to remove the message from the message port.  This could
)cause (actually it WILL cause) a GURU.
)
)Using the loop you have there, the line with the if(t->window...)
)should be replaced by:
)
)if(t->window==win)
){
)   Remove(t);
)   Reply(t);
)}
)
)>	    Permit();
)>	    CloseWindow(win);
)>	}

I think you've got it close, but the neatest way to walk an exec list
with the option of removing/replying the current node is probably:

	for ( node = list->lh_Head; succ = node->ln_Succ; node = succ )

    jimm

-- 
--------------------------------------------------	- opinions by me
"This voice console is a *must*.  I press Execute. 
 `Hello, I know that you've been feeling tired.
  I bring you love and deeper understanding.' "		-lyrics by Kate Bush
Technical Details
Message-ID: <5016@amiga.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!sun-barr!oliveb!amiga!jimm
References: <5740@cps3xx.UUCP> <8976@cbmvax.commodore.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!sun-barr!oliveb!amiga!jimm
From: jimm@amiga.UUCP (Jim Mackraz)
Newsgroups: comp.sys.amiga.tech
Subject: Re: CloseWindowSafely
Message-ID: <5016@amiga.UUCP>
Date: 13 Dec 89 20:00:28 GMT
References: <5740@cps3xx.UUCP> <8976@cbmvax.commodore.com>
Reply-To: jimm@batgirl.UUCP (Jim Mackraz)
Organization: Commodore-Amiga Inc, Los Gatos CA
Lines: 48