-
Notifications
You must be signed in to change notification settings - Fork 15.2k
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: prevent Menu.buildFromTemplate with empty array #23308
Conversation
Would the crash in original issue still happen when calling |
Just to give a usecase. We have a wrapper package around electron window creation/menu creation. It exposes a WindowBuilder, TrayBuilder, MenuBuilder etc (using a fluent API/builder pattern to compose the electron application). In this wrapper code we called a code similar to
Of course the issue should be prevented in our code by adding defensive checks and not call That said, I'd still prefer an early failure which doesn't result in a crash. (I mean a crash shouldn't ever happen no matter how insanely the JavaScript API was (ab)used.) Either:
In both cases the documentation should mention the behavior when |
@zcbenz it shouldn't from my read of this function, but i could be wrong! |
6b307fc
to
bf4c875
Compare
Release Notes Persisted
|
I was unable to backport this PR to "8-x-y" cleanly; |
I was unable to backport this PR to "7-2-x" cleanly; |
I have automatically backported this PR to "9-x-y", please check out #23351 |
@codebytere has manually backported this PR to "8-x-y", please check out #23353 |
@codebytere has manually backported this PR to "7-2-x", please check out #23354 |
New information came to light about how this may break existing codepaths - i'm going to open a new PR that avoids this breakage and backport that. |
Description of Change
Closes #23282.
Prevent issues with menu creation and subsequent pane focus from menu bar by preventing menus from being created from an empty array. I can't conceive a valid use case for this, since if one wants to remove a menu they should be be passing
null
towin.setMenu()
or callingwin.removeMenu()
. This issue is also specific to top-level menus, and not submenus, so the new check and exception is scoped to top-level menus.cc @zcbenz @jkleinsc @MarshallOfSound
Checklist
npm test
passesRelease Notes
Notes: Fixed a potential crash when menu is created from an empty template.