mirror of
https://github.com/electron/electron.git
synced 2026-01-25 23:38:18 -05:00
Verify selectedIndex to prevent NSRangeException
This commit is contained in:
@@ -465,7 +465,8 @@ static NSTouchBarItemIdentifier SegmentedControlIdentifier = @"com.electron.touc
|
||||
|
||||
int selectedIndex = 0;
|
||||
settings.Get("selectedIndex", &selectedIndex);
|
||||
control.selectedSegment = selectedIndex;
|
||||
if (selectedIndex >= 0 && selectedIndex < control.segmentCount)
|
||||
control.selectedSegment = selectedIndex;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -45,8 +45,9 @@ describe('TouchBar module', function () {
|
||||
new TouchBarSegmentedControl({
|
||||
segmentStyle: 'capsule',
|
||||
segments: [{label: 'baz', enabled: false}],
|
||||
selectedIndex: 0
|
||||
})
|
||||
selectedIndex: 5
|
||||
}),
|
||||
new TouchBarSegmentedControl({segments: []})
|
||||
])
|
||||
window.setTouchBar(touchBar)
|
||||
label.label = 'baz'
|
||||
|
||||
Reference in New Issue
Block a user