Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from Apr 13, 2020

Conversation

CezaryKulakowski
Copy link
Contributor

@CezaryKulakowski CezaryKulakowski commented Mar 12, 2020

Closes #22671.

Fixes an issue with possible creation of a messageBox which cannot be dismissed on macOS.

Checklist

Release Notes

Notes: Fixed an issue with possible creation of a messageBox which cannot be dismissed on macOS.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Mar 12, 2020
Without this change it's possible to create message box which can't
be dismissed on mac.
Copy link
Member

@codebytere codebytere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified locally - thanks for the fix!

@codebytere
Copy link
Member

@CezaryKulakowski this appears to be causing a crash on Linux.

@CezaryKulakowski
Copy link
Contributor Author

@codebytere this fix changes only mm file which is not being compiled on linux or windows.

@codebytere
Copy link
Member

@CezaryKulakowski misread - you're correct. Thought it was a .cc file on first glance.

Copy link
Member

@MarshallOfSound MarshallOfSound left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we document this behavior and tell folks to avoid this scenario to call window.show() before opening the modal?

@codebytere
Copy link
Member

@MarshallOfSound in that case, would we want to show the window ourselves if it's hidden before invoking the message box? I wanted to avoid the breaking change in this PR but it might be something to consider

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Mar 13, 2020
@CezaryKulakowski
Copy link
Contributor Author

@MarshallOfSound what do you mean by documenting this behavior and telling folks to avoid this scenario to call window.show() before opening the modal? Leaving it as it is now and adding some information to documentation? The scenario leading to it isn't very unusual and it breaks the ui.

@MarshallOfSound
Copy link
Member

Leaving it as it is now and adding some information to documentation?

Yes exactly that

@zcbenz
Copy link
Member

zcbenz commented Mar 20, 2020

@MarshallOfSound @CezaryKulakowski Maybe we can do this fix and document it explicitly? The showMessageBoxSync is totally broken under this case, I don't think we should just leave a broken case there and tell users not to do it in the documentation.

@@ -98,7 +98,7 @@ int ShowMessageBoxSync(const MessageBoxSettings& settings) {

// Use runModal for synchronous alert without parent, since we don't have a
// window to wait for.
if (!settings.parent_window)
if (!settings.parent_window || !settings.parent_window->IsVisible())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should leave a comment on why IsVisible is checked here.

@zcbenz
Copy link
Member

zcbenz commented Mar 25, 2020

@CezaryKulakowski Can you also document this behavior? (On macOS showing message box on invisible parent window would behave the same with no parent window.)

@MarshallOfSound Are you OK with both documenting this scenario and having a workaround?

@CezaryKulakowski
Copy link
Contributor Author

@zcbenz I've pushed a fixup which updates documentation. I hope this is what you meant.

@zcbenz zcbenz merged commit c65f41d into electron:master Apr 13, 2020
@release-clerk
Copy link

release-clerk bot commented Apr 13, 2020

Release Notes Persisted

Fixed an issue with possible creation of a messageBox which cannot be dismissed on macOS.

@trop
Copy link
Contributor

trop bot commented Apr 13, 2020

I have automatically backported this PR to "8-x-y", please check out #23088

@trop
Copy link
Contributor

trop bot commented Apr 13, 2020

I have automatically backported this PR to "7-2-x", please check out #23089

@trop
Copy link
Contributor

trop bot commented Apr 13, 2020

I have automatically backported this PR to "9-x-y", please check out #23090

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

message box can't be dismissed on mac
4 participants