Path: utzoo!attcan!uunet!wuarchive!brutus.cs.uiuc.edu!tut.cis.ohio-state.edu!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: Menubar updating Message-ID: <8321@hoptoad.uucp> Date: 17 Aug 89 22:09:35 GMT References: <15029@dartvax.Dartmouth.EDU> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Eclectic Software, San Francisco Lines: 36 In article <15029@dartvax.Dartmouth.EDU> isle@eleazar.dartmouth.edu (Ken Hancock) writes: >I'm writing a DA, and like all good little DA's, it will >remove it's menu from the MenuBar when not frontmost. >The only probelm is, that no matter what code I use, >I sometimes get a Disposed menu in the menubar >(clicking on it will of course crash the system...) > >Now the only time that the menu is actually Disposed of is after >I receive an accClose and have closed the driver. Does anyone know >what I'm doing wrong? Your code looks OK, but it's too interpretive. The menu bar is a system data structure and where Inside Macintosh imposes a specific protocol on how to use the system data structure, you should try to abide by it as closely as possible. IM I-446-7 makes it clear that desk accessories should install their menus when they get activate events and remove them when they get deactivate events. You seem to be doing it on every event instead, checking to see if your window is the front window. Try it the traditional way and see if there's any change. And no, I don't know exactly what's happening there. I would speculate that someone is doing a GetMenuBar while your menu is up, then restoring it with SetMenuBar when your menu is not up. The Menu Manager does some fairly tricky things with the menu list and this could cause problems -- as I recall, I had a similar problem with Moire a little more than a year ago. This may or may not be the answer, but in any case, try it the traditional way and see what happens. -- Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com "What's bad? What's the use of turning? In Hell I'll be there a-burning! Meanwhile, think of what I'm earning! All on account of my name." - Bill Sykes, "Oliver"