mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-16 01:02:30 +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
@@ -212,10 +212,11 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)lockAllDocuments {
|
- (void)lockAllDocuments {
|
||||||
for(NSDocument *document in [[NSDocumentController sharedDocumentController] documents]) {
|
for(NSDocument *document in ((NSDocumentController *)[NSDocumentController sharedDocumentController]).documents) {
|
||||||
NSArray *windowControllers = [document windowControllers];
|
for(id windowController in document.windowControllers) {
|
||||||
if([windowControllers count] > 0) {
|
if([windowController respondsToSelector:@selector(lock)]) {
|
||||||
[windowControllers[0] lock:nil];
|
[windowController lock];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -235,6 +236,12 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi
|
|||||||
NSArray *documents = [documentController documents];
|
NSArray *documents = [documentController documents];
|
||||||
BOOL restoredWindows = [documents count] > 0;
|
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 reopen = [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyReopenLastDatabaseOnLaunch];
|
||||||
BOOL showWelcomeScreen = !restoredWindows && !_shouldOpenFile;
|
BOOL showWelcomeScreen = !restoredWindows && !_shouldOpenFile;
|
||||||
if(reopen && !restoredWindows && !_shouldOpenFile) {
|
if(reopen && !restoredWindows && !_shouldOpenFile) {
|
||||||
|
|||||||
@@ -126,8 +126,6 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
|||||||
if(self) {
|
if(self) {
|
||||||
_didLockFile = NO;
|
_didLockFile = NO;
|
||||||
_readOnly = NO;
|
_readOnly = NO;
|
||||||
self.tree = [KPKTree allocTemplateTree];
|
|
||||||
self.tree.metaData.rounds = [[NSUserDefaults standardUserDefaults] integerForKey:kMPSettingsKeyDefaultPasswordRounds];
|
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@@ -136,6 +134,15 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
|||||||
[self _cleanupLock];
|
[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 {
|
- (void)makeWindowControllers {
|
||||||
MPDocumentWindowController *windowController = [[MPDocumentWindowController alloc] init];
|
MPDocumentWindowController *windowController = [[MPDocumentWindowController alloc] init];
|
||||||
[self addWindowController:windowController];
|
[self addWindowController:windowController];
|
||||||
@@ -234,6 +241,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
|||||||
if([[self fileURL] isFileURL]) {
|
if([[self fileURL] isFileURL]) {
|
||||||
[[NSUserDefaults standardUserDefaults] setObject:[self.fileURL absoluteString] forKey:kMPSettingsKeyLastDatabasePath];
|
[[NSUserDefaults standardUserDefaults] setObject:[self.fileURL absoluteString] forKey:kMPSettingsKeyLastDatabasePath];
|
||||||
}
|
}
|
||||||
|
self.tree = nil;
|
||||||
[super close];
|
[super close];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,16 +418,16 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
|||||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentCurrentItemChangedNotification object:self];
|
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentCurrentItemChangedNotification object:self];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
- (void)setTree:(KPKTree *)tree {
|
//- (void)setTree:(KPKTree *)tree {
|
||||||
if(_tree != tree) {
|
// if(_tree != tree) {
|
||||||
_tree = tree;
|
// _tree = tree;
|
||||||
_tree.undoManager = [self undoManager];
|
// _tree.undoManager = [self undoManager];
|
||||||
if(nil == _treeDelgate) {
|
// if(nil == _treeDelgate) {
|
||||||
_treeDelgate = [[MPTreeDelegate alloc] initWithDocument:self];
|
// _treeDelgate = [[MPTreeDelegate alloc] initWithDocument:self];
|
||||||
}
|
// }
|
||||||
_tree.delegate = _treeDelgate;
|
// _tree.delegate = _treeDelgate;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
#pragma mark Data Accesors
|
#pragma mark Data Accesors
|
||||||
|
|
||||||
|
|||||||
@@ -124,6 +124,8 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc {
|
- (void)dealloc {
|
||||||
|
[self.entryTable unbind:NSContentArrayBinding];
|
||||||
|
[self.entryArrayController unbind:NSContentArrayBinding];
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,6 +389,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
return; // we are showing the correct object right now.
|
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.entryArrayController bind:NSContentArrayBinding toObject:document.selectedGroup withKeyPath:NSStringFromSelector(@selector(entries)) options:nil];
|
||||||
}
|
}
|
||||||
[self _updateContextBar];
|
[self _updateContextBar];
|
||||||
@@ -423,7 +426,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
NSAssert(result != nil, @"Resutls should never be nil");
|
NSAssert(result != nil, @"Resutls should never be nil");
|
||||||
self.filteredEntries = result;
|
self.filteredEntries = result;
|
||||||
[self.entryArrayController unbind:NSContentArrayBinding];
|
[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];
|
[[self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier] setHidden:NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,6 +435,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
[[self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier] setHidden:YES];
|
[[self.entryTable tableColumnWithIdentifier:MPEntryTableParentColumnIdentifier] setHidden:YES];
|
||||||
MPDocument *document = [[self windowController] document];
|
MPDocument *document = [[self windowController] document];
|
||||||
document.selectedItem = document.selectedGroup;
|
document.selectedItem = document.selectedGroup;
|
||||||
|
// TODO: really necessary?
|
||||||
if( nil == document.selectedItem && nil == document.selectedGroup ) {
|
if( nil == document.selectedItem && nil == document.selectedGroup ) {
|
||||||
[self.entryArrayController unbind:NSContentArrayBinding];
|
[self.entryArrayController unbind:NSContentArrayBinding];
|
||||||
[self.entryArrayController setContent:nil];
|
[self.entryArrayController setContent:nil];
|
||||||
@@ -737,6 +741,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
#pragma mark periodic UI Update
|
#pragma mark periodic UI Update
|
||||||
|
|
||||||
- (void)_updateExpirationDisplay {
|
- (void)_updateExpirationDisplay {
|
||||||
|
return;
|
||||||
/* items are all entries */
|
/* items are all entries */
|
||||||
[[self.entryArrayController arrangedObjects] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
[[self.entryArrayController arrangedObjects] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||||
[[obj timeInfo] isExpired];
|
[[obj timeInfo] isExpired];
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc {
|
- (void)dealloc {
|
||||||
|
[self.outlineView unbind:NSContentBinding];
|
||||||
|
[self.treeController unbind:NSContentBinding];
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
[self.outlineView setDelegate:nil];
|
[self.outlineView setDelegate:nil];
|
||||||
}
|
}
|
||||||
@@ -299,6 +301,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)_updateExpirationDisplay {
|
- (void)_updateExpirationDisplay {
|
||||||
|
return;
|
||||||
MPDocument *document = [[self windowController] document];
|
MPDocument *document = [[self windowController] document];
|
||||||
[document.root.timeInfo isExpired];
|
[document.root.timeInfo isExpired];
|
||||||
[[document.tree allGroups] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
[[document.tree allGroups] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||||
|
|||||||
Reference in New Issue
Block a user