Skip to content

Commit

Permalink
Change the way the NSOpenPanel is handled when selecting an SSH key t…
Browse files Browse the repository at this point in the history
…o address #2042
  • Loading branch information
Max Lohrmann committed Jan 13, 2015
1 parent f2bb111 commit e9b8c38
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Source/SPConnectionController.m
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,7 @@ - (IBAction)chooseKeyLocation:(NSButton *)sender
#ifndef SP_CODA
NSString *directoryPath = nil;
NSString *filePath = nil;
keySelectionPanel = [NSOpenPanel openPanel];
[keySelectionPanel setShowsHiddenFiles:[prefs boolForKey:SPHiddenKeyFileVisibilityKey]];
NSView *accessoryView = nil;

// If the button was toggled off, ensure editing is ended
if ([sender state] == NSOffState) {
Expand All @@ -395,7 +394,7 @@ - (IBAction)chooseKeyLocation:(NSButton *)sender
directoryPath = [sshKeyLocation stringByDeletingLastPathComponent];
}

[keySelectionPanel setAccessoryView:sshKeyLocationHelp];
accessoryView = sshKeyLocationHelp;
}
// SSL key file location:
else if (sender == standardSSLKeyFileButton || sender == socketSSLKeyFileButton || sender == sslOverSSHKeyFileButton) {
Expand All @@ -404,7 +403,7 @@ - (IBAction)chooseKeyLocation:(NSButton *)sender
return;
}

[keySelectionPanel setAccessoryView:sslKeyFileLocationHelp];
accessoryView = sslKeyFileLocationHelp;
}
// SSL certificate file location:
else if (sender == standardSSLCertificateButton || sender == socketSSLCertificateButton || sender == sslOverSSHCertificateButton) {
Expand All @@ -413,7 +412,7 @@ - (IBAction)chooseKeyLocation:(NSButton *)sender
return;
}

[keySelectionPanel setAccessoryView:sslCertificateLocationHelp];
accessoryView = sslCertificateLocationHelp;
}
// SSL CA certificate file location:
else if (sender == standardSSLCACertButton || sender == socketSSLCACertButton || sender == sslOverSSHCACertButton) {
Expand All @@ -422,12 +421,21 @@ - (IBAction)chooseKeyLocation:(NSButton *)sender
return;
}

[keySelectionPanel setAccessoryView:sslCACertLocationHelp];
accessoryView = sslCACertLocationHelp;
}

keySelectionPanel = [[NSOpenPanel openPanel] retain]; // retain/release needed on OS X ≤ 10.6 according to Apple doc
[keySelectionPanel setShowsHiddenFiles:[prefs boolForKey:SPHiddenKeyFileVisibilityKey]];
[keySelectionPanel setAccessoryView:accessoryView];

[keySelectionPanel beginSheetModalForWindow:[dbDocument parentWindow] completionHandler:^(NSInteger returnCode)
{
NSString *abbreviatedFileName = [[[keySelectionPanel URL] path] stringByAbbreviatingWithTildeInPath];

//delay the release so it won't happen while this block is still executing.
dispatch_async(dispatch_get_current_queue(), ^{
SPClear(keySelectionPanel);
});

// SSH key file selection
if (sender == sshSSHKeyButton) {
Expand Down

0 comments on commit e9b8c38

Please sign in to comment.