From 16be427a926a2b2f82cd89dd31be05d50ef2cce8 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Fri, 1 Oct 2021 10:23:44 +0200 Subject: [PATCH] Used scoped tooling from KeePassKit --- MacPass/MPDocument.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 65f484ca..0a137eb1 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -681,8 +681,9 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou KPKEntry *newEntry = [self.tree createEntry:parent]; /* setting properties on entries is undoable, but we do not want to record this so disable on creation */ - BOOL wasUndoEnabeld = self.undoManager.isUndoRegistrationEnabled; - [self.undoManager disableUndoRegistration]; + + KPK_SCOPED_DISABLE_UNDO_BEGIN(self.undoManager) + newEntry.title = NSLocalizedString(@"DEFAULT_ENTRY_TITLE", @"Title for a newly created entry"); if([self.tree.metaData.defaultUserName length] > 0) { newEntry.username = self.tree.metaData.defaultUserName; @@ -696,10 +697,9 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou newEntry.password = defaultPassword; } } - /* re-enable undo/redo if we did turn it off */ - if(wasUndoEnabeld) { - [self.undoManager enableUndoRegistration]; - } + + KPK_SCOPED_DISABLE_UNDO_END + [newEntry addToGroup:parent]; [newEntry.undoManager setActionName:NSLocalizedString(@"NEW_ENTRY", "Action name for a newly created entry")]; [NSNotificationCenter.defaultCenter postNotificationName:MPDocumentDidAddEntryNotification