[net.micro.mac] Finder/DA bug

sakw@cvaxa.UUCP (Sak Wathanasin) (06/18/86)

>In response to a query in Delphi Digest Vol2 #22, I posted a response from
>Paul Russell about a bug he had discovered to do with using menus from within
>a DA. This produced the following response                    

From: Larry Rosenstein <lsr@apple.uucp>
Posted-Date: Mon, 16 Jun 86 18:18:11 pdt
To: sakw@uk.ac.sussex.cvaxa
Subject: Re: DA/Finder Menu Bug (Delphi Digest Vol2 #22)

This bug has nothing to do with the Finder; the information in MacTutor is
wrong. 

On the old ROMs it has always been a bug to call GetMenu twice for the same
menu.  This is documented in Inside Macintosh Volume I page I-352.  

The reasons is that the call to GetMenu replaces the procID from the
resource file with a handle to the menu defProc.  If you call it again while
the menu is in memory, it will treat the defProc handle as a procID.

Since GetMenu call the menu defproc to calculate its size, calling GetMenu
twice probably sets the defproc to garbage, which could jump anywhere in
memory.  This might account for the report in MacTutor that the Finder jumps
into the ROM.

I have heard that the new 128K ROM catches this case and will not modify
the defProc handle if it is already a procID.  I don't know if this is true
or not.

I don't know why the DA example in TML Pascal does work from within
applications other than the Finder.  I am not familiar with TML Pascal.
 
Your information looks pretty good, except that the DA's Open routine is
called each time the DA is chosen from the Apple menu.  The DA might not
have been closed before it is told to Open again.  Your Open routine should
check to see if your DA's window has been created before calling GetMenu.
(If the window exists, the DA is already Opened.)

If you know that your menu is installed in the menu bar, you can call the
routine GetMHandle (see the Menu Manager documentation).  This is like your
GetMenuH routine, but searches through the menus currently installed in the
menu bar.  (Plus is is in ROM.)

I would appreciate it if you forward this information to Usenet.  Right now
our news program is broken, so I cannot post any articles.  Thanks.


Larry Rosenstein

Object Specialist
Apple Computer

UUCP:  {sun, voder, nsc, mtxinu, dual}!apple!lsr
CSNET: lsr@Apple.CSNET
-- 
Sak Wathanasin, U of Sussex, Cognitive Studies, Falmer, Sussex BN1 9QN, UK
uucp:  ...mcvax!ukc!cvaxa!sakw
arpa:  sakw%cvaxa.sussex.ac.uk@ucl.cs.ac.uk
janet: sakw@uk.ac.sussex.cvaxa