Verify selectedIndex to prevent NSRangeException
This commit is contained in:
parent
3b2faf7b89
commit
3349e32196
2 changed files with 5 additions and 3 deletions
|
@ -465,7 +465,8 @@ static NSTouchBarItemIdentifier SegmentedControlIdentifier = @"com.electron.touc
|
||||||
|
|
||||||
int selectedIndex = 0;
|
int selectedIndex = 0;
|
||||||
settings.Get("selectedIndex", &selectedIndex);
|
settings.Get("selectedIndex", &selectedIndex);
|
||||||
control.selectedSegment = selectedIndex;
|
if (selectedIndex >= 0 && selectedIndex < control.segmentCount)
|
||||||
|
control.selectedSegment = selectedIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -45,8 +45,9 @@ describe('TouchBar module', function () {
|
||||||
new TouchBarSegmentedControl({
|
new TouchBarSegmentedControl({
|
||||||
segmentStyle: 'capsule',
|
segmentStyle: 'capsule',
|
||||||
segments: [{label: 'baz', enabled: false}],
|
segments: [{label: 'baz', enabled: false}],
|
||||||
selectedIndex: 0
|
selectedIndex: 5
|
||||||
})
|
}),
|
||||||
|
new TouchBarSegmentedControl({segments: []})
|
||||||
])
|
])
|
||||||
window.setTouchBar(touchBar)
|
window.setTouchBar(touchBar)
|
||||||
label.label = 'baz'
|
label.label = 'baz'
|
||||||
|
|
Loading…
Reference in a new issue