• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Toolbar customizer crashes on Leopard when using menu delegate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Toolbar customizer crashes on Leopard when using menu delegate


  • Subject: Re: Toolbar customizer crashes on Leopard when using menu delegate
  • From: Peter Ammon <email@hidden>
  • Date: Thu, 25 Mar 2010 11:20:46 -0700

On Mar 25, 2010, at 9:10 AM, Markus Spoettl wrote:

> Hi Peter,
>
> On Mar 24, 2010, at 11:13 PM, Peter Ammon wrote:
>> Yes, this is a known problem on Leopard.  The issue is that when NSToolbar shows the customization palette, well, a view can't be in the toolbar and the customization palette simultaneously, so NSToolbar "copies" the popup via NSKeyedArchiver.  Unfortunately, NSMenu's encodeWithCoder: method encodes its delegate unconditionally, and if the delegate doesn't implement NSCoding, you get an exception.
>>
>> In SnowLeopard, NSToolbar was revamped to render the views into images and show the images - not the views - in the customization palette.  So NSToolbar in SnowLeopard no longer "copies" views, which is why the problem does not reproduce.
>>
>> I think the easiest workaround is to implement NSCoding on your NSMenu delegate.  The delegate doesn't have to do a very good job encoding itself, because the delegate will not actually be used in the customization palette.  In fact, you may be able to get away with implementing replacementObjectForCoder: on your delegate to just return nil.
>
>
> Thanks a lot for the detailed explanation. Something else must be playing into this because my delegate is an NSWindowController subclass which already conforms to the NSCoding protocol. A second instance actually gets created during the customizer setup, but it's dealloc'd before the crash happens.

Delegates aren't retained by the menu, so when NSToolbar copies the menu, it will create a new instance of your delegate which will then soon be deallocated because nothing retains it.  If the delegate isn't removed from the menu, then the menu will crash when it tries to talk to the delegate.  So another fix would be to remove your delegate from the menu in the -dealloc method.

-Peter

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Toolbar customizer crashes on Leopard when using menu delegate (From: Markus Spoettl <email@hidden>)
 >Re: Toolbar customizer crashes on Leopard when using menu delegate (From: Peter Ammon <email@hidden>)
 >Re: Toolbar customizer crashes on Leopard when using menu delegate (From: Markus Spoettl <email@hidden>)

  • Prev by Date: Prevent NSWindow from hiding with app
  • Next by Date: Re: Prevent NSWindow from hiding with app
  • Previous by thread: Re: Toolbar customizer crashes on Leopard when using menu delegate
  • Next by thread: NSTreeController, NSBrowser image setting
  • Index(es):
    • Date
    • Thread