mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 02:22:28 +00:00
Merge pull request #465 from eouw0o83hf/master
Fixed #464 stop multiple file-changed boxes from appearing at once
This commit is contained in:
@@ -75,6 +75,8 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
|||||||
@property (strong) IBOutlet NSView *warningView;
|
@property (strong) IBOutlet NSView *warningView;
|
||||||
@property (weak) IBOutlet NSImageView *warningViewImage;
|
@property (weak) IBOutlet NSImageView *warningViewImage;
|
||||||
|
|
||||||
|
@property (assign) BOOL fileChangeDialogOpen;;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation MPDocument
|
@implementation MPDocument
|
||||||
@@ -115,6 +117,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
|||||||
if(self) {
|
if(self) {
|
||||||
_didLockFile = NO;
|
_didLockFile = NO;
|
||||||
_readOnly = NO;
|
_readOnly = NO;
|
||||||
|
_fileChangeDialogOpen = NO;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@@ -244,15 +247,26 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
|||||||
if(NSOrderedSame == [self.fileModificationDate compare:modificationDate]) {
|
if(NSOrderedSame == [self.fileModificationDate compare:modificationDate]) {
|
||||||
return; // Just metadata has changed
|
return; // Just metadata has changed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(_fileChangeDialogOpen) {
|
||||||
|
return; // This alert is already being shown
|
||||||
|
}
|
||||||
|
|
||||||
/* Dispatch the alert to the main queue */
|
/* Dispatch the alert to the main queue */
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
|
||||||
|
_fileChangeDialogOpen = YES;
|
||||||
|
|
||||||
NSAlert *alert = [[NSAlert alloc] init];
|
NSAlert *alert = [[NSAlert alloc] init];
|
||||||
alert.alertStyle = NSWarningAlertStyle;
|
alert.alertStyle = NSWarningAlertStyle;
|
||||||
alert.messageText = NSLocalizedString(@"FILE_CHANGED_BY_OTHERS_MESSAGE_TEXT", @"Message displayed when an open file was changed from another application");
|
alert.messageText = NSLocalizedString(@"FILE_CHANGED_BY_OTHERS_MESSAGE_TEXT", @"Message displayed when an open file was changed from another application");
|
||||||
alert.informativeText = NSLocalizedString(@"FILE_CHANGED_BY_OTHERS_INFO_TEXT", @"Informative text displayed when the file was change form another application");
|
alert.informativeText = NSLocalizedString(@"FILE_CHANGED_BY_OTHERS_INFO_TEXT", @"Informative text displayed when the file was change from another application");
|
||||||
[alert addButtonWithTitle:NSLocalizedString(@"KEEP_MINE", @"Ignore the changes to an open file!")];
|
[alert addButtonWithTitle:NSLocalizedString(@"KEEP_MINE", @"Ignore the changes to an open file!")];
|
||||||
[alert addButtonWithTitle:NSLocalizedString(@"LOAD_CHANGES", @"Reopen the file!")];
|
[alert addButtonWithTitle:NSLocalizedString(@"LOAD_CHANGES", @"Reopen the file!")];
|
||||||
[alert beginSheetModalForWindow:self.windowForSheet completionHandler:^(NSModalResponse returnCode) {
|
[alert beginSheetModalForWindow:self.windowForSheet completionHandler:^(NSModalResponse returnCode) {
|
||||||
|
|
||||||
|
_fileChangeDialogOpen = NO;
|
||||||
|
|
||||||
if(returnCode == NSAlertSecondButtonReturn) {
|
if(returnCode == NSAlertSecondButtonReturn) {
|
||||||
[self revertDocumentToSaved:nil];
|
[self revertDocumentToSaved:nil];
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
MacPassTests/.DS_Store
vendored
Normal file
BIN
MacPassTests/.DS_Store
vendored
Normal file
Binary file not shown.
Reference in New Issue
Block a user