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 event leak on reuse of touchbar item #12527

Merged
merged 2 commits into from Apr 15, 2018

Conversation

Projects
None yet
3 participants
@MarshallOfSound
Member

MarshallOfSound commented Apr 4, 2018

Fixes #12508

@MarshallOfSound MarshallOfSound requested a review from electron/reviewers as a code owner Apr 4, 2018

@nornagon

It's confusing that there are two things called changeListener, but it looks like you got the right one. 👍

@@ -118,6 +118,9 @@ class TouchBar extends EventEmitter {
window.removeListener('closed', removeListeners)
window._touchBar = null
delete this.windowListeners[id]
for (const item of this.ordereredItems) {
item.removeListener('change', this.changeListener)

This comment has been minimized.

@ckerr

ckerr Apr 4, 2018

Member

I think this is undoing the item.on('change', this.changeListener) in registerItem(), but the next line there is to also register each of item.child.ordereredItems iff item.child is a TouchBar. Do we need to undo that here too?

If we don't also need that, then I'm 👍 on this PR

This comment has been minimized.

@ckerr

ckerr Apr 4, 2018

Member

edit: and walking recursively down all TouchBar subtrees

This comment has been minimized.

@ckerr

ckerr Apr 4, 2018

Member

edit 2: do we also need to remove the escapeItem changeListener too?

This comment has been minimized.

@MarshallOfSound

MarshallOfSound Apr 12, 2018

Member

I now clean up recursively and deal with the escapeItem listener

@@ -118,6 +118,9 @@ class TouchBar extends EventEmitter {
window.removeListener('closed', removeListeners)
window._touchBar = null
delete this.windowListeners[id]
for (const item of this.ordereredItems) {

This comment has been minimized.

@ckerr

ckerr Apr 4, 2018

Member

'ordereredItems'? not new to this PR, but... 🙄 😄

This comment has been minimized.

@MarshallOfSound

MarshallOfSound Apr 12, 2018

Member

items is a map of id --> item
orderedItems is an array giving you the left->right order of those items containing references to the objects in the items map

This comment has been minimized.

@ckerr

ckerr Apr 15, 2018

Member

Right, I get it. Just amused by the spelling ordereredItems 🥈

This comment has been minimized.

@MarshallOfSound

MarshallOfSound Apr 15, 2018

Member

Oh, wow, ok. That's a typo I never noticed 😆

@ckerr

ckerr approved these changes Apr 15, 2018

Thanks for the changes!

@ckerr ckerr merged commit 7cc3b87 into master Apr 15, 2018

8 checks passed

WIP ready for review
Details
ci/circleci: electron-linux-arm Your tests passed on CircleCI!
Details
ci/circleci: electron-linux-arm-test Your tests passed on CircleCI!
Details
ci/circleci: electron-linux-arm64 Your tests passed on CircleCI!
Details
ci/circleci: electron-linux-arm64-test Your tests passed on CircleCI!
Details
ci/circleci: electron-linux-ia32 Your tests passed on CircleCI!
Details
ci/circleci: electron-linux-x64 Your tests passed on CircleCI!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details

@ckerr ckerr deleted the event-leak branch Apr 15, 2018

@trop

This comment has been minimized.

Contributor

trop bot commented Apr 15, 2018

We have automatically backported this PR to "1-8-x", please check out #12623

@trop

This comment has been minimized.

Contributor

trop bot commented Apr 15, 2018

We have automatically backported this PR to "2-0-x", please check out #12624

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment