Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: DebuggingCarbonLib assertion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DebuggingCarbonLib assertion



. . . .The code is calling various menu functions on a menu which was created like so:
mMenu = NewMenu( menuID, "\p" );
InsertMenu( mMenu, kInsertHierarchicalMenu );

I decided to use CreateNewMenu() instead of NewMenu() under Carbon, since I was tired of specifying empty menu titles half the time. I've made a lot of hierarchical menus this way, too. Maybe using the new API will avoid the bug (if there is one)?

No, I'm not calling GetMenuItemHierarchicalMenu. I was calling InsertMenuItem("\psomething",0); on a menu that's on the hierarchical menu list.

Remember that InsertMenuItem() is an interpolating function...it parses the text you provide, and uses it to determine menu item attributes (some of which may be completely invalid for a hierarchical menu, such as a key equivalent). A long time ago, I got sick of tracking bugs caused by my forgetting about this, and got in the habit of doing things like this:
InsertMenuItem(menu, "\p", afterItem);
SetMenuItemText( . . .);

Carbon has InsertMenuItemText(), however, which is an interpolation-free version of the function, and might help you avoid bugs.

Kevin G.


References: 
 >Re: DebuggingCarbonLib assertion (From: John Stiles <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.