Used scoped tooling from KeePassKit

This commit is contained in:
Michael Starke
2021-10-01 10:23:44 +02:00
parent 48fc70018e
commit 16be427a92

View File

@@ -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