Skip to content

Commit

Permalink
Fixed #1206 that would cancel version browsing in time machine if the…
Browse files Browse the repository at this point in the history
… key file open panel is shown
  • Loading branch information
mstarke committed Feb 9, 2022
1 parent 43e667a commit 0a6ba80
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions MacPass/MPPathControl.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ - (instancetype)initWithFrame:(NSRect)frameRect {
- (instancetype)initWithCoder:(NSCoder *)coder {
/* FIXME: this doesn't work well anymore. Need more work, see: https://www.mikeash.com/pyblog/custom-nscells-done-right.html */
self = [super initWithCoder:coder];
self.delegate = self;
self.delegate = self;
[self _setupCell];
return self;
}
Expand All @@ -68,11 +68,24 @@ - (void)showOpenPanel:(id)sender {
if([self.delegate respondsToSelector:@selector(pathControl:willDisplayOpenPanel:)]) {
[self.delegate pathControl:self willDisplayOpenPanel:panel];
}
[panel beginWithCompletionHandler:^(NSModalResponse result) {
if(result == NSModalResponseOK) {
self.URL = panel.URLs.firstObject;
}
}];
// fall back to modal sheet when browsing Versions. Otherwise we would get kicked out of the TimeMachien UI
// #1206 See Unable to use Time Machine function when have a KeyFile
// Setting NSDocumentRevisionsDebugMode=1 will prevent TimeMachien from exiting even when the openPanel is not shown as sheet
NSDocument *document = self.window.windowController.document;
if(document.isInViewingMode) {
[panel beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse result) {
if(result == NSModalResponseOK) {
self.URL = panel.URLs.firstObject;
}
}];
}
else {
[panel beginWithCompletionHandler:^(NSModalResponse result) {
if(result == NSModalResponseOK) {
self.URL = panel.URLs.firstObject;
}
}];
}
}

- (void)pathControl:(NSPathControl *)pathControl willDisplayOpenPanel:(NSOpenPanel *)openPanel {
Expand Down

0 comments on commit 0a6ba80

Please sign in to comment.