From 1eb248553a17fef1f4ed8e7d5011d1102d22a331 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Wed, 23 Jul 2025 11:54:03 -0400 Subject: [PATCH] Unregister Zotero_Tabs observers when window is unloaded --- chrome/content/zotero/tabs.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/tabs.js b/chrome/content/zotero/tabs.js index 726277d8d9..0772b3317e 100644 --- a/chrome/content/zotero/tabs.js +++ b/chrome/content/zotero/tabs.js @@ -77,10 +77,10 @@ var Zotero_Tabs = new function () { this._focusOptions = {}; // Keep track of item modifications to update the title - Zotero.Notifier.registerObserver(this, ['item'], 'tabs'); + this._notifierID = Zotero.Notifier.registerObserver(this, ['item'], 'tabs'); // Update the title when pref of title format is changed - Zotero.Prefs.registerObserver('tabs.title.reader', async () => { + this._prefsObserverID = Zotero.Prefs.registerObserver('tabs.title.reader', async () => { for (let tab of this._tabs) { if (!tab.data.itemID) continue; let item = Zotero.Items.get(tab.data.itemID); @@ -88,6 +88,11 @@ var Zotero_Tabs = new function () { this.rename(tab.id, title); } }); + + window.addEventListener('unload', () => { + Zotero.Notifier.unregisterObserver(this._notifierID); + Zotero.Prefs.unregisterObserver(this._prefsObserverID); + }); this._unloadInterval = setInterval(() => { this.unloadUnusedTabs();