Fix a memory leak in file renaming preferences pane (#3654)
This commit is contained in:
parent
f8108aca45
commit
493c3add8a
3 changed files with 22 additions and 2 deletions
|
@ -102,6 +102,13 @@ var Zotero_Preferences = {
|
||||||
Zotero.Prefs.unregisterObserver(symbol);
|
Zotero.Prefs.unregisterObserver(symbol);
|
||||||
}
|
}
|
||||||
this._observerSymbols.clear();
|
this._observerSymbols.clear();
|
||||||
|
|
||||||
|
for (let [_key, pane] of this.panes) {
|
||||||
|
for (let child of pane.container.children) {
|
||||||
|
let event = new Event('unload');
|
||||||
|
child.dispatchEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
waitForFirstPaneLoad: async function () {
|
waitForFirstPaneLoad: async function () {
|
||||||
|
|
|
@ -31,7 +31,16 @@ Zotero_Preferences.FileRenaming = {
|
||||||
this.inputRef = document.getElementById('file-renaming-format-template');
|
this.inputRef = document.getElementById('file-renaming-format-template');
|
||||||
this.updatePreview();
|
this.updatePreview();
|
||||||
this.inputRef.addEventListener('input', this.updatePreview.bind(this));
|
this.inputRef.addEventListener('input', this.updatePreview.bind(this));
|
||||||
Zotero.getActiveZoteroPane()?.itemsView.onSelect.addListener(this.updatePreview.bind(this));
|
|
||||||
|
this._itemsView = Zotero.getActiveZoteroPane()?.itemsView;
|
||||||
|
this._updatePreview = this.updatePreview.bind(this);
|
||||||
|
if (this._itemsView) {
|
||||||
|
this._itemsView.onSelect.addListener(this._updatePreview);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
uninit: function () {
|
||||||
|
this._itemsView.onSelect.removeListener(this._updatePreview);
|
||||||
},
|
},
|
||||||
|
|
||||||
getActiveTopLevelItem() {
|
getActiveTopLevelItem() {
|
||||||
|
|
|
@ -22,7 +22,11 @@
|
||||||
|
|
||||||
***** END LICENSE BLOCK *****
|
***** END LICENSE BLOCK *****
|
||||||
-->
|
-->
|
||||||
<vbox class="main-section" id="zotero-prefpane-file-renaming-format" onload="Zotero_Preferences.FileRenaming.init()">
|
<vbox
|
||||||
|
class="main-section" id="zotero-prefpane-file-renaming-format"
|
||||||
|
onload="Zotero_Preferences.FileRenaming.init()"
|
||||||
|
onunload="Zotero_Preferences.FileRenaming.uninit()"
|
||||||
|
>
|
||||||
<hbox class="header">
|
<hbox class="header">
|
||||||
<html:h1 data-l10n-id="preferences-file-renaming-format-title" />
|
<html:h1 data-l10n-id="preferences-file-renaming-format-title" />
|
||||||
</hbox>
|
</hbox>
|
||||||
|
|
Loading…
Reference in a new issue