mirror of https://github.com/ksherlock/ample.git
don't crash if a slot is empty (laser3000, which has no slots and no disk drives)
This commit is contained in:
parent
6b2c4c408a
commit
62767971ee
|
@ -131,11 +131,15 @@ static NSDictionary *IndexMap = nil;
|
||||||
|
|
||||||
-(SlotOption *)selectedItem {
|
-(SlotOption *)selectedItem {
|
||||||
if (_selectedIndex < 0) return nil;
|
if (_selectedIndex < 0) return nil;
|
||||||
|
if (_selectedIndex >= [_options count]) return nil;
|
||||||
|
|
||||||
return [_options objectAtIndex: _selectedIndex];
|
return [_options objectAtIndex: _selectedIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSArray *)args {
|
-(NSArray *)args {
|
||||||
if (_selectedIndex < 0) return nil;
|
if (_selectedIndex < 0) return nil;
|
||||||
|
if (_selectedIndex >= [_options count]) return nil;
|
||||||
|
|
||||||
NSMutableArray *rv = [NSMutableArray new];
|
NSMutableArray *rv = [NSMutableArray new];
|
||||||
SlotOption *option = [_options objectAtIndex: _selectedIndex];
|
SlotOption *option = [_options objectAtIndex: _selectedIndex];
|
||||||
|
|
||||||
|
@ -145,6 +149,8 @@ static NSDictionary *IndexMap = nil;
|
||||||
|
|
||||||
-(NSDictionary *)serialize {
|
-(NSDictionary *)serialize {
|
||||||
if (_selectedIndex < 0) return nil;
|
if (_selectedIndex < 0) return nil;
|
||||||
|
if (_selectedIndex >= [_options count]) return nil;
|
||||||
|
|
||||||
|
|
||||||
NSMutableDictionary *d = [NSMutableDictionary new];
|
NSMutableDictionary *d = [NSMutableDictionary new];
|
||||||
SlotOption *option = [_options objectAtIndex: _selectedIndex];
|
SlotOption *option = [_options objectAtIndex: _selectedIndex];
|
||||||
|
@ -209,6 +215,7 @@ static NSDictionary *IndexMap = nil;
|
||||||
-(Media)selectedMedia {
|
-(Media)selectedMedia {
|
||||||
|
|
||||||
if (_selectedIndex < 0) return EmptyMedia;
|
if (_selectedIndex < 0) return EmptyMedia;
|
||||||
|
if (_selectedIndex >= [_options count]) return EmptyMedia;
|
||||||
|
|
||||||
Media media = { 0 };
|
Media media = { 0 };
|
||||||
SlotOption *option = [_options objectAtIndex: _selectedIndex];
|
SlotOption *option = [_options objectAtIndex: _selectedIndex];
|
||||||
|
@ -221,6 +228,8 @@ static NSDictionary *IndexMap = nil;
|
||||||
|
|
||||||
-(NSArray *)selectedChildren {
|
-(NSArray *)selectedChildren {
|
||||||
if (_selectedIndex < 0) return nil;
|
if (_selectedIndex < 0) return nil;
|
||||||
|
if (_selectedIndex >= [_options count]) return nil;
|
||||||
|
|
||||||
return [[_options objectAtIndex: _selectedIndex] children];
|
return [[_options objectAtIndex: _selectedIndex] children];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue