From 64dfd99089d35731fa6cf6b65df59aee75c90cb6 Mon Sep 17 00:00:00 2001 From: Owen Yamauchi Date: Thu, 29 Jan 2009 23:19:00 -0500 Subject: [PATCH] Make finding the history/commit selector more robust. Shouldn't assume that the selector is the first item in the toolbar; the user could have moved it. --- PBGitWindowController.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/PBGitWindowController.m b/PBGitWindowController.m index 8314feb..4899ed0 100644 --- a/PBGitWindowController.m +++ b/PBGitWindowController.m @@ -112,7 +112,13 @@ - (void) useToolbar:(NSToolbar *)toolbar { - NSSegmentedControl *item = (NSSegmentedControl *)[[[toolbar items] objectAtIndex:0] view]; + NSSegmentedControl *item = nil; + for (NSToolbarItem *toolbarItem in [toolbar items]) { + if ([[toolbarItem view] isKindOfClass:[NSSegmentedControl class]]) { + item = (NSSegmentedControl *)[toolbarItem view]; + break; + } + } [item bind:@"selectedIndex" toObject:self withKeyPath:@"selectedViewIndex" options:0]; [self.window setToolbar:toolbar];