Path: 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 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