Skip to content

fix: crash when tray popup called twice - #18999

Merged
codebytere merged 1 commit into
masterfrom
double-popup-dont-crash
Jun 28, 2019
Merged

codebytere merged 1 commit into
masterfrom
double-popup-dont-crash

Conversation

@codebytere

@codebytere codebytere commented Jun 27, 2019 •

Copy link
Copy Markdown
Member

Description of Change

When the Tray popup functionality was made asynchronous, ScopedPumpMessagesInPrivateModes was introduced to ensure that the UI can update while the menu is fading out. However, given that we're now asynchronous, there exists a possibility that we can call popUpContextMenu more than once and this will cause a crash since we're no longer blocking the main process.

As a result, we only want to call ScopedPumpMessagesInPrivateModes if we're going to open the menu, which means that we first need to ensure that the menu is not already open. This PR thus fixes the aforementioned crash which can be seen in the following code before this PR and is fixed with the code therein.

  tray.setContextMenu(contextMenu)
  tray.popUpContextMenu()
  tray.popUpContextMenu()

cc @deermichel @miniak

Checklist

Release Notes

Notes: Fixed a crash on tray popup being called multiple times in a row.

@codebytere
codebytere requested review from deermichel and miniak June 27, 2019 05:12
@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Jun 27, 2019
@deermichel

deermichel commented Jun 27, 2019 •

Copy link
Copy Markdown
Contributor

Works for me. Can you add a test for this or is testing tray stuff difficult on CI?

@codebytere

codebytere commented Jun 27, 2019 •

Copy link
Copy Markdown
Member Author

@deermichel the tray tests don't work presently on Mac (you'll see they get skipped for all except windows) so for now no but i was planning to dig further into trying to add some/make em work on macOS once your PR to move tray tests into the main spec runner gets merged 🚀

@deermichel deermichel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

aight, then go ahead 🎈

@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Jun 28, 2019
@codebytere
codebytere merged commit a4f6156 into master Jun 28, 2019
@release-clerk

release-clerk Bot commented Jun 28, 2019

Copy link
Copy Markdown

Release Notes Persisted

Fixed a crash on tray popup being called multiple times in a row.

@codebytere
codebytere deleted the double-popup-dont-crash branch June 28, 2019 15:24
MarshallOfSound pushed a commit that referenced this pull request Jul 31, 2019
* restore stash

revert

some things work others dont

tracking area for rescue

manual popup

restore drag n drop

cleanup

* fix: make tray not block main process (#18880)

* fix: make tray not block main process

* make AtomMenuModel refcounted

* add support for ansi codes in title

add remove TODOs

* chore: use ScopedPumpMessagesInPrivateModes in tray (#18977)

* chore: use ScopedPumpMessagesInPrivateModes in tray

* revert refcounting of AtomMenuModel

* Prefer WeakPtr for posting tasks to handle unexpected destruction

* cleanup .h

* cleanup .mm

* add imports

add missing include

* fix: crash when tray popup called twice (#18999)

* remove highlightMode and TODOs

* remove unnecessary copy
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.

4 participants