fix: dialog fails to show after modal close (#22858)

This commit is contained in:
Shelley Vohr 2020-03-30 09:48:20 -07:00 committed by GitHub
parent c085d3bf12
commit b14608c2c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 18 deletions

View file

@ -270,6 +270,19 @@ using TitleBarStyle = electron::NativeWindowMac::TitleBarStyle;
- (void)windowWillClose:(NSNotification*)notification {
shell_->NotifyWindowClosed();
// Something called -[NSWindow close] on a sheet rather than calling
// -[NSWindow endSheet:] on its parent. If the modal session is not ended
// then the parent will never be able to show another sheet. But calling
// -endSheet: here will block the thread with an animation, so post a task.
if (shell_->is_modal() && shell_->parent() && shell_->IsVisible()) {
NSWindow* window = shell_->GetNativeWindow().GetNativeNSWindow();
NSWindow* sheetParent = [window sheetParent];
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(base::RetainBlock(^{
[sheetParent endSheet:window];
})));
}
// Clears the delegate when window is going to be closed, since EL Capitan it
// is possible that the methods of delegate would get called after the window
// has been closed.