On 5/8/06 11:01 AM, Douglas Norton didst favor us with:
On 8 May 2006, at 15:49, Norio Ota wrote:
I am about to attach a menu reference created programmatically to a
popup control.
Is the menu reference freed when the control is disposed?
yes
Or do I have to release it by myself?
and yes.
MenuRef rMenu = NewMenu(...) // retain count = 1;
SetControlPopupMenuHandle( hControl, rMenu ); // retain count = 2
// don't forget these
// SetControlMinimum( hControl, 0 );
// SetControlMaximum( hControl, CountMenuItems( rMenu ) );
ReleaseMenu( rMenu ) // retain count = 1
...
...
...
...
// later when window / dialog disposed of
// Either
DisposeWindow( win ); // tears down controls in window
// or
DisposeControl( hControl ) // => Control releases menu, retain count
= 0, menu dies.
Hope that helps,
Yes, but now I'm kind of confused. In this post:
http://lists.apple.com/archives/Carbon-development/2001/Jun/
msg01512.html
Eric says that "you won't need SetControlPopupMenuHandle if you use
SetControlData with kControlPopupButtonOwnedMenuRefTag. They both
do the
same thing."
And I have a note in my own records that says:
"pascal void SetControlPopupMenuHandle( ControlRef control, MenuRef
menu )
{
OSStatus error;
error = SetControlData( control, kControlNoPart,
kControlPopupButtonMenuHandleTag, sizeof( menu ), (Ptr)&menu );
check_noerr( error );
}
-eric"
Do kControlPopupButtonMenuHandleTag and
kControlPopupButtonOwnedMenuRefTag
do the same thing?
Larry