From 957e8bab5a2aec3be70d828e38a44cd09ab7a463 Mon Sep 17 00:00:00 2001 From: michael starke Date: Tue, 3 Sep 2013 21:20:09 +0200 Subject: [PATCH] Fixed save issue that resulted in appkit throwing an error because of atomic write option Fixed issue with wrong file type being selected in save dialog Fixed issue with hidden warning box on save dialog when data loss will occur --- MacPass/MPDocument.h | 2 +- MacPass/MPDocument.m | 7 +++++-- MacPass/MPSavePanelAccessoryViewController.m | 12 +++++++++--- MacPass/MacPass-Info.plist | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/MacPass/MPDocument.h b/MacPass/MPDocument.h index fdc0537b..9d240cc0 100644 --- a/MacPass/MPDocument.h +++ b/MacPass/MPDocument.h @@ -42,7 +42,7 @@ APPKIT_EXTERN NSString *const MPDocumnetDidChangeCurrentEntryNotification; @property (nonatomic, strong) NSURL *key; @property (assign, readonly, getter = isReadOnly) BOOL readOnly; - +@property (nonatomic, readonly, assign) KPKVersion versionForFileType; /* State (active group/entry) diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index c87608ff..ebc3679a 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -83,7 +83,6 @@ typedef NS_ENUM(NSUInteger, MPAlertType) { _didLockFile = NO; _hasPasswordOrKey = NO; _readOnly = NO; - [self setFileType:MPXMLDocumentUTI]; self.tree = [KPKTree templateTree]; } return self; @@ -113,7 +112,7 @@ typedef NS_ENUM(NSUInteger, MPAlertType) { return NO; } NSData *treeData = [self.tree encryptWithPassword:password forVersion:version error:outError]; - if([treeData writeToURL:url options:NSDataWritingAtomic error:outError]) { + if(![treeData writeToURL:url options:0 error:outError]) { NSLog(@"%@", [*outError localizedDescription]); return NO; } @@ -208,6 +207,10 @@ typedef NS_ENUM(NSUInteger, MPAlertType) { #pragma mark Properties +- (KPKVersion)versionForFileType { + return [[self class] versionForFileType:[self fileType]]; +} + - (BOOL)encrypted { return (self.tree == nil); } diff --git a/MacPass/MPSavePanelAccessoryViewController.m b/MacPass/MPSavePanelAccessoryViewController.m index 55776326..364158b7 100644 --- a/MacPass/MPSavePanelAccessoryViewController.m +++ b/MacPass/MPSavePanelAccessoryViewController.m @@ -52,8 +52,7 @@ else if([uti isEqualToString:MPLegacyDocumentUTI]) { self.selectedVersion = KPKXmlVersion; } - BOOL showInfoText = (self.document.tree.minimumVersion == KPKLegacyVersion && [uti isEqualToString:MPLegacyDocumentUTI]); - [self.infoTextField setHidden:!showInfoText]; + [self _updateNote]; [self.savePanel setAllowedFileTypes:@[uti]]; } @@ -65,7 +64,7 @@ } - (void)_updateView { - switch(self.document.tree.minimumVersion) { + switch(self.document.versionForFileType) { case KPKLegacyVersion: [self.fileTypePopupButton selectItemAtIndex:1]; break; @@ -76,6 +75,13 @@ NSAssert(NO, @"Minimum Version should always be valid"); break; } + [self _updateNote]; +} + +- (void)_updateNote { + NSString *uti = [[self.fileTypePopupButton selectedItem] representedObject]; + BOOL showInfoText = (self.document.tree.minimumVersion == KPKXmlVersion && [uti isEqualToString:MPLegacyDocumentUTI]); + [self.infoTextField setHidden:!showInfoText]; } @end diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index 366de210..5c6c4db5 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -56,7 +56,7 @@ CFBundleSignature ???? CFBundleVersion - 2527 + 2528 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright