Skip navigation.
 
mlNSToolbar doesn't add default items issue on 10.5.2
FROM : Martin Redington
DATE : Thu Mar 27 18:58:11 2008

I've got some NSToolbar code, which seems to have suddenly stopped 
working on Leopard only.

- (void) setupToolbar
{
   NSLog(@"Setting up toolbar");
   
//    [self removeObsoleteToolbarIdentifiers];

    NSToolbar *toolbar = [[MMICleanerToolbar alloc] 
initWithIdentifier:@"CleanerToolbar"];

    [toolbar setAllowsUserCustomization:YES];
    [toolbar setAutosavesConfiguration:YES];
    [toolbar setDelegate:self];
   
    NSLog(@"Setting toolbar %@ for window %@", toolbar, 
mMainCleanerWindow);
    [mMainCleanerWindow setToolbar:toolbar];
    // release it as well? TODO
    NSLog(@"Set up toolbar");
}

MMICleanerToolbar is a subclass of NSToolbar, but actually doesn't 
implement any methods, so it's an NSToolbar for all intents and 
purposes.

On Tiger, I can see the delegates -toolbarDefaultItemIdentifiers: 
method get called, followed by the NSToolbarItem calls, after the 
setToolbar: method.

On Leopard (10.5.2/9C31) [latest security update not installed yet], 
the delegate methods aren't getting called, and I get an empty 
toolbar, which looks to be slightly less tall than the standard 
toolbar with small items.

I rolled back over a few revisions of my app, and they all seem to be 
affected, so it doesn't seem like I've broken anything recently. The 
first user report I got for this was today (in fact I got two).

As I workaround, I'm checking [[toolbar items] count], after 
setToolbar: and manually inserting the default item set if the 
toolbar is empty.

Related mailsAuthorDate
mlNSToolbar doesn't add default items issue on 10.5.2 Martin Redington Mar 27, 18:58
mlRe: NSToolbar doesn't add default items issue on 10.5.2 Peter Ammon Mar 27, 20:34
mlRe: NSToolbar doesn't add default items issue on 10.5.2 Martin Redington Mar 28, 01:43
mlRe: NSToolbar doesn't add default items issue on 10.5.2 Martin Redington Mar 28, 16:12