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

Merged
merged 2 commits into from
Apr 15, 2018
Merged

Fix event leak on reuse of touchbar item #12527

merged 2 commits into from
Apr 15, 2018

Conversation

MarshallOfSound
Copy link
Member

Fixes #12508

Copy link
Member

@nornagon nornagon left a comment

Choose a reason for hiding this comment

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

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)
Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Member

Choose a reason for hiding this comment

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

edit: and walking recursively down all TouchBar subtrees

Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Member Author

@MarshallOfSound MarshallOfSound Apr 12, 2018

Choose a reason for hiding this comment

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

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) {
Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Member Author

Choose a reason for hiding this comment

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

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

Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Member Author

Choose a reason for hiding this comment

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

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

Copy link
Member

@ckerr ckerr left a comment

Choose a reason for hiding this comment

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

Thanks for the changes!

@ckerr ckerr merged commit 7cc3b87 into master Apr 15, 2018
@ckerr ckerr deleted the event-leak branch April 15, 2018 15:24
@trop
Copy link
Contributor

trop bot commented Apr 15, 2018

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

@trop
Copy link
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants