From 1d3b911b16a715574abdfaf391e60b39d46f3724 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 25 Jul 2019 12:28:41 -0400 Subject: [PATCH] macOS: Fix alert dialog display (fixes issue #2726) --- .../native/javascript_dialog_runner_mac.mm | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/libcef/browser/native/javascript_dialog_runner_mac.mm b/libcef/browser/native/javascript_dialog_runner_mac.mm index ccf58fbda..77fe7d357 100644 --- a/libcef/browser/native/javascript_dialog_runner_mac.mm +++ b/libcef/browser/native/javascript_dialog_runner_mac.mm @@ -26,8 +26,9 @@ (CefJavaScriptDialogRunner::DialogClosedCallback)callback; - (NSAlert*)alert; - (NSTextField*)textField; -- (void)alertDidEndWithResult:(NSModalResponse)returnCode - dialog:(CefJavaScriptDialogRunnerMac*)dialog; +- (void)alertDidEnd:(NSAlert*)alert + returnCode:(int)returnCode + contextInfo:(void*)contextInfo; - (void)cancel; @end @@ -57,8 +58,9 @@ return textField_; } -- (void)alertDidEndWithResult:(NSModalResponse)returnCode - dialog:(CefJavaScriptDialogRunnerMac*)dialog { +- (void)alertDidEnd:(NSAlert*)alert + returnCode:(int)returnCode + contextInfo:(void*)contextInfo { if (returnCode == NSModalResponseStop) return; @@ -139,11 +141,16 @@ void CefJavaScriptDialogRunnerMac::Run( // around the "callee requires a non-null argument" error that occurs when // building with the 10.11 SDK. See http://crbug.com/383820 for related // discussion. + // We can't use the newer beginSheetModalForWindow:completionHandler: variant + // because it fails silently when passed a nil argument (see issue #2726). id nilArg = nil; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" [alert beginSheetModalForWindow:nilArg // nil here makes it app-modal - completionHandler:^void(NSModalResponse returnCode) { - [helper_ alertDidEndWithResult:returnCode dialog:this]; - }]; + modalDelegate:helper_ + didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) + contextInfo:this]; +#pragma clang diagnostic pop if ([alert accessoryView]) [[alert window] makeFirstResponder:[alert accessoryView]];