From 4a31467afb5e3b7dd91da0def25b55f87b7315d0 Mon Sep 17 00:00:00 2001 From: Mathieu Monney Date: Mon, 17 Mar 2014 10:46:39 +0100 Subject: [PATCH] FIXED: CPSegementedControl with nib2cib crashes When having a CPSegmentedControl within a a XIB files, nib2cib crashes with the following error: ``` 'undefined' is not an object (evaluating 'self._themeStates[aSegment].without') ``` This pull request fixes the problem by making sure that the drawBezel method is called with a valid segment index when accessing the themeState. Reduction: https://dl.dropboxusercontent.com/u/14629300/BugCPSegmentedControl.zip --- AppKit/CPSegmentedControl.j | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/AppKit/CPSegmentedControl.j b/AppKit/CPSegmentedControl.j index 0853312f8..36a691035 100644 --- a/AppKit/CPSegmentedControl.j +++ b/AppKit/CPSegmentedControl.j @@ -476,10 +476,13 @@ CPSegmentSwitchTrackingMomentary = 2; */ - (void)drawSegmentBezel:(int)aSegment highlight:(BOOL)shouldHighlight { - if (shouldHighlight) - _themeStates[aSegment] = _themeStates[aSegment].and(CPThemeStateHighlighted); - else - _themeStates[aSegment] = _themeStates[aSegment].without(CPThemeStateHighlighted); + if(aSegment<_themeStates.length) + { + if (shouldHighlight) + _themeStates[aSegment] = _themeStates[aSegment].and(CPThemeStateHighlighted); + else + _themeStates[aSegment] = _themeStates[aSegment].without(CPThemeStateHighlighted); + } [self setNeedsLayout]; [self setNeedsDisplay:YES];