Fix event leak on reuse of touchbar item (#12527)
* fix event leak on reuse of touchbar item * Clean up child touch bar item event listeners and escape item listeners
This commit is contained in:
parent
cd8278dceb
commit
7cc3b877dc
1 changed files with 12 additions and 0 deletions
|
@ -118,6 +118,18 @@ class TouchBar extends EventEmitter {
|
|||
window.removeListener('closed', removeListeners)
|
||||
window._touchBar = null
|
||||
delete this.windowListeners[id]
|
||||
const unregisterItems = (items) => {
|
||||
for (const item of items) {
|
||||
item.removeListener('change', this.changeListener)
|
||||
if (item.child instanceof TouchBar) {
|
||||
unregisterItems(item.child.ordereredItems)
|
||||
}
|
||||
}
|
||||
}
|
||||
unregisterItems(this.ordereredItems)
|
||||
if (this.escapeItem) {
|
||||
this.escapeItem.removeListener('change', this.changeListener)
|
||||
}
|
||||
}
|
||||
window.once('closed', removeListeners)
|
||||
this.windowListeners[id] = removeListeners
|
||||
|
|
Loading…
Reference in a new issue