mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 16:22:21 +00:00
KeePassKit API changes. Fixed binding leak issue preventing the document from being deallocated
This commit is contained in:
Submodule KeePassKit updated: 3d2592c7b1...c385bd725c
@@ -66,10 +66,10 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi
|
||||
self = [super init];
|
||||
if(self) {
|
||||
/* We know that we do not use the varibale after instancation */
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-variable"
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-variable"
|
||||
MPDocumentController *documentController = [[MPDocumentController alloc] init];
|
||||
#pragma clang diagnostic pop
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -212,10 +212,11 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi
|
||||
}
|
||||
|
||||
- (void)lockAllDocuments {
|
||||
for(NSDocument *document in [[NSDocumentController sharedDocumentController] documents]) {
|
||||
NSArray *windowControllers = [document windowControllers];
|
||||
if([windowControllers count] > 0) {
|
||||
[windowControllers[0] lock:nil];
|
||||
for(NSDocument *document in ((NSDocumentController *)[NSDocumentController sharedDocumentController]).documents) {
|
||||
for(id windowController in document.windowControllers) {
|
||||
if([windowController respondsToSelector:@selector(lock)]) {
|
||||
[windowController lock];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -235,6 +236,12 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi
|
||||
NSArray *documents = [documentController documents];
|
||||
BOOL restoredWindows = [documents count] > 0;
|
||||
|
||||
for(NSDocument *document in documents) {
|
||||
for(NSWindowController *windowController in [document windowControllers]) {
|
||||
[windowController.window.contentView layout];
|
||||
}
|
||||
}
|
||||
|
||||
BOOL reopen = [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyReopenLastDatabaseOnLaunch];
|
||||
BOOL showWelcomeScreen = !restoredWindows && !_shouldOpenFile;
|
||||
if(reopen && !restoredWindows && !_shouldOpenFile) {
|
||||
|
||||
@@ -126,8 +126,6 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
if(self) {
|
||||
_didLockFile = NO;
|
||||
_readOnly = NO;
|
||||
self.tree = [KPKTree allocTemplateTree];
|
||||
self.tree.metaData.rounds = [[NSUserDefaults standardUserDefaults] integerForKey:kMPSettingsKeyDefaultPasswordRounds];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -136,6 +134,15 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
[self _cleanupLock];
|
||||
}
|
||||
|
||||
- (instancetype)initWithType:(NSString *)typeName error:(NSError *__autoreleasing *)outError {
|
||||
self = [self init];
|
||||
if(self) {
|
||||
self.tree = [[KPKTree alloc] initWithTemplateContents];
|
||||
self.tree.metaData.rounds = [[NSUserDefaults standardUserDefaults] integerForKey:kMPSettingsKeyDefaultPasswordRounds];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)makeWindowControllers {
|
||||
MPDocumentWindowController *windowController = [[MPDocumentWindowController alloc] init];
|
||||
[self addWindowController:windowController];
|
||||
@@ -234,6 +241,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
if([[self fileURL] isFileURL]) {
|
||||
[[NSUserDefaults standardUserDefaults] setObject:[self.fileURL absoluteString] forKey:kMPSettingsKeyLastDatabasePath];
|
||||
}
|
||||
self.tree = nil;
|
||||
[super close];
|
||||
}
|
||||
|
||||
@@ -410,16 +418,16 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentCurrentItemChangedNotification object:self];
|
||||
}
|
||||
}
|
||||
- (void)setTree:(KPKTree *)tree {
|
||||
if(_tree != tree) {
|
||||
_tree = tree;
|
||||
_tree.undoManager = [self undoManager];
|
||||
if(nil == _treeDelgate) {
|
||||
_treeDelgate = [[MPTreeDelegate alloc] initWithDocument:self];
|
||||
}
|
||||
_tree.delegate = _treeDelgate;
|
||||
}
|
||||
}
|
||||
//- (void)setTree:(KPKTree *)tree {
|
||||
// if(_tree != tree) {
|
||||
// _tree = tree;
|
||||
// _tree.undoManager = [self undoManager];
|
||||
// if(nil == _treeDelgate) {
|
||||
// _treeDelgate = [[MPTreeDelegate alloc] initWithDocument:self];
|
||||
// }
|
||||
// _tree.delegate = _treeDelgate;
|
||||
// }
|
||||
//}
|
||||
|
||||
#pragma mark Data Accesors
|
||||
|
||||
@@ -682,26 +690,26 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
id<MPTargetNodeResolving> nodeResolver = [NSApp targetForAction:@selector(currentTargetNode)];
|
||||
|
||||
/*
|
||||
NSLog(@"entryResolver:%@", [entryResolver class]);
|
||||
NSLog(@"groupResolver:%@", [groupResolver class]);
|
||||
NSLog(@"nodeResolver:%@", [nodeResolver class]);
|
||||
*/
|
||||
NSLog(@"entryResolver:%@", [entryResolver class]);
|
||||
NSLog(@"groupResolver:%@", [groupResolver class]);
|
||||
NSLog(@"nodeResolver:%@", [nodeResolver class]);
|
||||
*/
|
||||
|
||||
KPKNode *targetNode = [nodeResolver currentTargetNode];
|
||||
KPKEntry *targetEntry = [entryResolver currentTargetEntry];
|
||||
KPKGroup *targetGroup = [groupResolver currentTargetGroup];
|
||||
|
||||
/*
|
||||
if([targetNode asGroup]) {
|
||||
NSLog(@"targetNode:%@", ((KPKGroup *)targetNode).name);
|
||||
}
|
||||
else if([targetNode asEntry]) {
|
||||
NSLog(@"targetNode:%@", ((KPKEntry *)targetNode).title);
|
||||
}
|
||||
|
||||
NSLog(@"targetGroup:%@", targetGroup.name);
|
||||
NSLog(@"tagetEntry:%@", targetEntry.title );
|
||||
*/
|
||||
if([targetNode asGroup]) {
|
||||
NSLog(@"targetNode:%@", ((KPKGroup *)targetNode).name);
|
||||
}
|
||||
else if([targetNode asEntry]) {
|
||||
NSLog(@"targetNode:%@", ((KPKEntry *)targetNode).title);
|
||||
}
|
||||
|
||||
NSLog(@"targetGroup:%@", targetGroup.name);
|
||||
NSLog(@"tagetEntry:%@", targetEntry.title );
|
||||
*/
|
||||
|
||||
if(self.encrypted || self.isReadOnly) { return NO; }
|
||||
|
||||
|
||||
@@ -124,6 +124,8 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[self.entryTable unbind:NSContentArrayBinding];
|
||||
[self.entryArrayController unbind:NSContentArrayBinding];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
@@ -387,6 +389,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
||||
return; // we are showing the correct object right now.
|
||||
}
|
||||
}
|
||||
[self.entryArrayController unbind:NSContentArrayBinding];
|
||||
[self.entryArrayController bind:NSContentArrayBinding toObject:document.selectedGroup withKeyPath:NSStringFromSelector(@selector(entries)) options:nil];
|
||||
}
|
||||
[self _updateContextBar];
|
||||
@@ -423,7 +426,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
||||
NSAssert(result != nil, @"Resutls should never be nil");
|
||||
self.filteredEntries = result;
|
||||
[self.entryArrayController unbind:NSContentArrayBinding];
|
||||
[self.entryArrayController setContent:self.filteredEntries];
|
||||
[self.entryArrayController bind:NSContentArrayBinding toObject:self withKeyPath:NSStringFromSelector(@selector(filteredEntries)) options:nil];
|
||||
[[self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier] setHidden:NO];
|
||||
}
|
||||
|
||||
@@ -432,6 +435,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
||||
[[self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier] setHidden:YES];
|
||||
MPDocument *document = [[self windowController] document];
|
||||
document.selectedItem = document.selectedGroup;
|
||||
// TODO: really necessary?
|
||||
if( nil == document.selectedItem && nil == document.selectedGroup ) {
|
||||
[self.entryArrayController unbind:NSContentArrayBinding];
|
||||
[self.entryArrayController setContent:nil];
|
||||
@@ -737,6 +741,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
||||
#pragma mark periodic UI Update
|
||||
|
||||
- (void)_updateExpirationDisplay {
|
||||
return;
|
||||
/* items are all entries */
|
||||
[[self.entryArrayController arrangedObjects] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||
[[obj timeInfo] isExpired];
|
||||
|
||||
@@ -72,6 +72,8 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[self.outlineView unbind:NSContentBinding];
|
||||
[self.treeController unbind:NSContentBinding];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[self.outlineView setDelegate:nil];
|
||||
}
|
||||
@@ -299,6 +301,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
|
||||
}
|
||||
|
||||
- (void)_updateExpirationDisplay {
|
||||
return;
|
||||
MPDocument *document = [[self windowController] document];
|
||||
[document.root.timeInfo isExpired];
|
||||
[[document.tree allGroups] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||
|
||||
Reference in New Issue
Block a user