diff options
author | Damiano Galassi <[email protected]> | 2020-01-21 11:33:29 +0100 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2020-01-21 11:33:29 +0100 |
commit | 8966caad127cc10ff8c840ae3bcc665c2625755c (patch) | |
tree | 2d74f8df7f9e7c7137c8d76b65ac05a6f195e1bf /macosx | |
parent | 5ca812830dfd7558616ec81d566dfc08dc79a165 (diff) |
MacGui: remove all the undo actions after saving a preset, because undoing after the save could led to a weird state.
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/HBController.m | 20 | ||||
-rw-r--r-- | macosx/HBPresetsViewController.m | 10 |
2 files changed, 18 insertions, 12 deletions
diff --git a/macosx/HBController.m b/macosx/HBController.m index 780cbb359..cbbe99302 100644 --- a/macosx/HBController.m +++ b/macosx/HBController.m @@ -1452,19 +1452,25 @@ static void *HBControllerLogLevelContext = &HBControllerLogLevelContext; [self.window HB_endEditing]; NSIndexPath *indexPath = [presetManager indexPathOfPreset:self.selectedPreset]; - HBMutablePreset *preset = [self createPresetFromCurrentSettings]; - preset.name = self.selectedPreset.name; - preset.isDefault = self.selectedPreset.isDefault; + if (indexPath) + { + HBMutablePreset *preset = [self createPresetFromCurrentSettings]; + preset.name = self.selectedPreset.name; + preset.isDefault = self.selectedPreset.isDefault; - [presetManager replacePresetAtIndexPath:indexPath withPreset:preset]; + [presetManager replacePresetAtIndexPath:indexPath withPreset:preset]; - self.job.presetName = preset.name; - self.selectedPreset = preset; - fPresetsView.selectedPreset = preset; + self.job.presetName = preset.name; + self.selectedPreset = preset; + fPresetsView.selectedPreset = preset; + + [self.window.undoManager removeAllActions]; + } } - (IBAction)deletePreset:(id)sender { + fPresetsView.selectedPreset = presetManager.defaultPreset; [fPresetsView deletePreset:self]; } diff --git a/macosx/HBPresetsViewController.m b/macosx/HBPresetsViewController.m index d2528e738..4b4fcd66f 100644 --- a/macosx/HBPresetsViewController.m +++ b/macosx/HBPresetsViewController.m @@ -94,7 +94,7 @@ static void *HBPresetsViewControllerContext = &HBPresetsViewControllerContext; [self.outlineView setDraggingSourceOperationMask:NSDragOperationMove forLocal:YES]; // Re-expand the items - [self expandNodes:[self.treeController.arrangedObjects childNodes]]; + [self expandNodes:self.treeController.arrangedObjects.childNodes]; [self.treeController setSelectionIndexPath:[self.presets indexPathOfPreset:self.selectedPreset]]; [self.treeController addObserver:self forKeyPath:@"selectedObjects" options:NSKeyValueObservingOptionNew context:HBPresetsViewControllerContext]; @@ -123,14 +123,14 @@ static void *HBPresetsViewControllerContext = &HBPresetsViewControllerContext; if (action == @selector(exportPreset:)) { - if (![[self.treeController selectedObjects] firstObject]) + if (!self.treeController.selectedObjects.firstObject) { return NO; } } if (action == @selector(setDefault:)) { - if (![[[self.treeController selectedObjects] firstObject] isLeaf]) + if (![self.treeController.selectedObjects.firstObject isLeaf]) { return NO; } @@ -273,7 +273,7 @@ static void *HBPresetsViewControllerContext = &HBPresetsViewControllerContext; - (IBAction)deletePreset:(id)sender { - if ([self.treeController canRemove]) + if (self.treeController.canRemove) { // Alert user before deleting preset NSAlert *alert = [[NSAlert alloc] init]; @@ -352,7 +352,7 @@ static void *HBPresetsViewControllerContext = &HBPresetsViewControllerContext; [self.presets generateBuiltInPresets]; // Re-expand the items - [self expandNodes:[self.treeController.arrangedObjects childNodes]]; + [self expandNodes:self.treeController.arrangedObjects.childNodes]; } #pragma mark - Expanded node persistence methods |