summaryrefslogtreecommitdiffstats
path: root/macosx/HBPresetsManager.m
diff options
context:
space:
mode:
authorritsuka <[email protected]>2014-11-24 07:38:17 +0000
committerritsuka <[email protected]>2014-11-24 07:38:17 +0000
commit4ba9d1e4e38756ce309684c9b17738fba30e05ed (patch)
tree4e17c97964542749b98fe009cb5bb57146159c68 /macosx/HBPresetsManager.m
parent5d34dcc2d1f2cc6339491770808be52811728bc1 (diff)
MacGui: add a better check for regenerating the built-in presets after a user deletes everything.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6549 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/HBPresetsManager.m')
-rw-r--r--macosx/HBPresetsManager.m26
1 files changed, 22 insertions, 4 deletions
diff --git a/macosx/HBPresetsManager.m b/macosx/HBPresetsManager.m
index 778963b7d..f7b532107 100644
--- a/macosx/HBPresetsManager.m
+++ b/macosx/HBPresetsManager.m
@@ -105,9 +105,18 @@ NSString *HBPresetsChangedNotification = @"HBPresetsChangedNotification";
[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];
}
@@ -291,6 +300,7 @@ NSString *HBPresetsChangedNotification = @"HBPresetsChangedNotification";
{
__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.
@@ -301,8 +311,12 @@ NSString *HBPresetsChangedNotification = @"HBPresetsChangedNotification";
{
normalPreset = obj;
}
+ if (firstBuiltInPreset == nil)
+ {
+ firstBuiltInPreset = obj;
+ }
}
- else if ([obj isLeaf])
+ else if ([obj isLeaf] && firstUserPreset == nil)
{
firstUserPreset = obj;
*stop = YES;
@@ -319,6 +333,10 @@ NSString *HBPresetsChangedNotification = @"HBPresetsChangedNotification";
self.defaultPreset = firstUserPreset;
firstUserPreset.isDefault = YES;
}
+ else if (firstBuiltInPreset) {
+ self.defaultPreset = firstBuiltInPreset;
+ firstBuiltInPreset.isDefault = YES;
+ }
}
- (void)setDefaultPreset:(HBPreset *)defaultPreset