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
Here is what my testing just now shows in 10.3.9:
ItemCount ic = GetMenuRetainCount( menu );
// ic is 1
SetControlPopupMenuHandle( inPopup, menu );
ic = GetMenuRetainCount( menu );
// ic is still 1
SetControlData ( inPopup, kControlEntireControl,
kControlPopupButtonMenuRefTag, sizeof( MenuRef ), &menu );
and
SetControlData ( inPopup, kControlEntireControl,
kControlPopupButtonOwnedMenuRefTag, sizeof( MenuRef ), &menu );
both produce the same result as well.
Larry
>
> // 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,
>
> Douglas
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Carbon-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/carbon-dev/email@hidden
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden
This email sent to email@hidden