Fix event leak on reuse of touchbar item by MarshallOfSound · Pull Request #12527 · electron/electron · GitHub
Skip to content

Fix event leak on reuse of touchbar item#12527

Merged
ckerr merged 2 commits into
masterfrom
event-leak
Apr 15, 2018
Merged

Fix event leak on reuse of touchbar item#12527
ckerr merged 2 commits into
masterfrom
event-leak

Conversation

@MarshallOfSound

Copy link
Copy Markdown
Member

Fixes #12508

@nornagon nornagon 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.

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

Comment thread lib/browser/api/touch-bar.js Outdated

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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?

@MarshallOfSound MarshallOfSound Apr 12, 2018

Copy link
Copy Markdown
Member Author

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

Comment thread lib/browser/api/touch-bar.js Outdated
window.removeListener('closed', removeListeners)
window._touchBar = null
delete this.windowListeners[id]
for (const item of this.ordereredItems) {

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 😆

@ckerr ckerr left a comment

Copy link
Copy Markdown
Member

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

trop Bot commented Apr 15, 2018

Copy link
Copy Markdown
Contributor

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

@trop

trop Bot commented Apr 15, 2018

Copy link
Copy Markdown
Contributor

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