[presetsArray release];
- // If the preset list is empty,
- // readd the built in presets.
- if (self.root.children.count == 0)
+ // If the preset list contains no leaf,
+ // add back the built in presets.
+ __block BOOL leafFound = NO;
+ [self.root enumerateObjectsUsingBlock:^(id obj, NSIndexPath *idx, BOOL *stop) {
+ if ([obj isLeaf])
+ {
+ leafFound = YES;
+ *stop = YES;
+ }
+ }];
+
+ if (!leafFound)
{
[self generateBuiltInPresets];
}
{
__block HBPreset *normalPreset = nil;
__block HBPreset *firstUserPreset = nil;
+ __block HBPreset *firstBuiltInPreset = nil;
// Search for a possibile new default preset
// Try to use "Normal" or the first user preset.
{
normalPreset = obj;
}
+ if (firstBuiltInPreset == nil)
+ {
+ firstBuiltInPreset = obj;
+ }
}
- else if ([obj isLeaf])
+ else if ([obj isLeaf] && firstUserPreset == nil)
{
firstUserPreset = obj;
*stop = YES;
self.defaultPreset = firstUserPreset;
firstUserPreset.isDefault = YES;
}
+ else if (firstBuiltInPreset) {
+ self.defaultPreset = firstBuiltInPreset;
+ firstBuiltInPreset.isDefault = YES;
+ }
}
- (void)setDefaultPreset:(HBPreset *)defaultPreset