fix: don't assign NSAlert to window which is not visible (#23089)

* fix: don't assign NSAlert to window which is not visible

Without this change it's possible to create message box which can't
be dismissed on mac.

* fixup! fix: don't assign NSAlert to window which is not visible

* fixup! fix: don't assign NSAlert to window which is not visible

* Update docs/api/dialog.md

Co-authored-by: Cezary Kulakowski <cezary@openfin.co>
Co-authored-by: John Kleinschmidt <jkleinsc@github.com>
This commit is contained in:
trop[bot]
2020-04-14 10:57:22 -04:00
committed by GitHub
parent 372c5b9518
commit 97010bf947
2 changed files with 5 additions and 2 deletions

View File

@@ -254,6 +254,7 @@ Shows a message box, it will block the process until the message box is closed.
It returns the index of the clicked button.
The `browserWindow` argument allows the dialog to attach itself to a parent window, making it modal.
If the `browserWindow` is not shown, the dialog will not be attached to it. In that case it will be displayed as an independent window.
### `dialog.showMessageBox([browserWindow, ]options)`

View File

@@ -97,8 +97,10 @@ int ShowMessageBoxSync(const MessageBoxSettings& settings) {
NSAlert* alert = CreateNSAlert(settings);
// Use runModal for synchronous alert without parent, since we don't have a
// window to wait for.
if (!settings.parent_window)
// window to wait for. Also use it when window is provided but it is not
// shown as it would be impossible to dismiss the alert if it is connected
// to invisible window (see #22671).
if (!settings.parent_window || !settings.parent_window->IsVisible())
return [[alert autorelease] runModal];
__block int ret_code = -1;