From 46d066394f1a12d2f490b8312e36b40516f7e5c2 Mon Sep 17 00:00:00 2001 From: Martynas Bagdonas Date: Wed, 26 Jul 2023 17:08:42 +0300 Subject: [PATCH] Temporary fix for tab crashes caused by tab loading racing conditions --- chrome/content/zotero/tabs.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/tabs.js b/chrome/content/zotero/tabs.js index bb9fbf5645..72ba46c5fb 100644 --- a/chrome/content/zotero/tabs.js +++ b/chrome/content/zotero/tabs.js @@ -87,6 +87,9 @@ var Zotero_Tabs = new function () { const multipleTabsOpen = this._tabs.length > 1; document.getElementById('cmd_close').setAttribute('disabled', multipleTabsOpen); var { tab } = this._getTab(this._selectedID); + if (!tab) { + return; + } document.title = (tab.title.length ? tab.title + ' - ' : '') + Zotero.appName; this._updateTabBar(); // Hide any tab `title` tooltips that might be open @@ -276,6 +279,7 @@ var Zotero_Tabs = new function () { if (tab.id == this._prevSelectedID) { this._prevSelectedID = null; } + tabIndex = this._tabs.findIndex(x => x.id === id); this._tabs.splice(tabIndex, 1); document.getElementById(tab.id).remove(); // For unknown reason fx102, unlike 60, sometimes doesn't automatically update selected index @@ -364,7 +368,9 @@ var Zotero_Tabs = new function () { } if (this._selectedID) { let { tab: selectedTab } = this._getTab(this._selectedID); - selectedTab.timeUnselected = Zotero.Date.getUnixTimestamp(); + if (selectedTab) { + selectedTab.timeUnselected = Zotero.Date.getUnixTimestamp(); + } } if (tab.type === 'reader-unloaded') { this.close(tab.id);