#8 ✓fixreleased
Brandon Walkin

Selectable toolbar leaks and crash fixes

Reported by Brandon Walkin | August 28th, 2009 @ 01:40 AM

Hey,

BWSelectableToolbar is rather leaky (checked-out yesterday) and if you adopt the strategy of releasing the toolbar's parent window when you're done with it, you'll get a crash if you create the window again.

The attached patch corrects those issues but it's not a fully-tested solution because I've had to give up on using your toolbar.

Even with my patch it still leaks a string (matching one of your hard-coded itemIdentifiers) each time I re-open my prefs window.

Hopefully the patch is of some value.

Regards, Trevor


Comment thread from previous issue tracker:

bwalkin:

Thanks for the fixes, Trevor. I patched the class accordingly. http://bitbucket.org/bwalkin/bwtoolkit/changeset/c9c21694d014/ http://bitbucket.org/bwalkin/bwtoolkit/changeset/dc8add6f0030/ Regarding your comments in the .diff, the reason I'm using static variables is a bit complicated. When you drag a NSToolbar based library item (say a BWSelectableToolbar) to the design surface, it will instantiate two toolbar objects, one is a BWSelectableToolbar and that's your "document object". The other is a subclass of BWSelectableToolbar that IB generates called IBEditableBWSelectableToolbar. I need both of these objects to be able to reference each other, and the only way I know how to do that is by storing references to each as static variables that both classes can access. If I (or someone else) can find a way to do this without using static variables, then I'll be able to make the toolbar significantly more stable and resolve most (if not all) of the known issues listed in the release notes.

bwalkin:

Figured it out. The key is overriding -(id)configurableToolbar. This is the method that IB calls when it wants to create an editable subclass of your toolbar class. The object that's returned is the new editable toolbar object. So override -configurableToolbar and catch the reference to super's new configurable (editable) toolbar before returning it. That'll give you a reference to the editable toolbar from the document toolbar. Getting the reference the other way is easy, just set the documentToolbar ivar on the editable toolbar to self (since this method will only be ran on a document toolbar).

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

BWToolkit is an Interface Builder plugin that contains commonly used UI elements and other objects designed to simplify Mac development.

Shared Ticket Bins

People watching this ticket

Pages