commit 7cd143992860ae0e0c7eab7e8b100ea4730cfffd parent fa33eb72b20a20974e1b422014f09f360b44a265 Author: Dan Stillman <dstillman@zotero.org> Date: Mon, 18 Dec 2017 02:55:24 -0500 Hopefully fix intermittently broken items pane https://forums.zotero.org/discussion/69226/papers-become-invisible-in-the-middle-pane I can't reproduce this, but it seems like if the tree disappears (due to a collection change?) while the tree is refreshing, the toggleSelect() in the rememberSelection() call can fail and break the tree. Diffstat:
| M | chrome/content/zotero/xpcom/itemTreeView.js | | | 50 | ++++++++++++++++++++++++++++++-------------------- |
1 file changed, 30 insertions(+), 20 deletions(-)
diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js @@ -2103,30 +2103,40 @@ Zotero.ItemTreeView.prototype.rememberSelection = function (selection) { var unsuppress = this.selection.selectEventsSuppressed = true; this._treebox.beginUpdateBatch(); } - for(var i=0; i < selection.length; i++) - { - if (this._rowMap[selection[i]] != null) { - this.selection.toggleSelect(this._rowMap[selection[i]]); - } - // Try the parent - else { - var item = Zotero.Items.get(selection[i]); - if (!item) { - continue; - } - - var parent = item.parentItemID; - if (!parent) { - continue; - } - - if (this._rowMap[parent] != null) { - this._closeContainer(this._rowMap[parent]); - this.toggleOpenState(this._rowMap[parent]); + + // Use try/catch to work around NS_ERROR_UNEXPECTED from nsITreeSelection::toggleSelect(), + // apparently when the tree disappears before it's called (though I can't reproduce it): + // + // https://forums.zotero.org/discussion/69226/papers-become-invisible-in-the-middle-pane + try { + for (let i = 0; i < selection.length; i++) { + if (this._rowMap[selection[i]] != null) { this.selection.toggleSelect(this._rowMap[selection[i]]); } + // Try the parent + else { + var item = Zotero.Items.get(selection[i]); + if (!item) { + continue; + } + + var parent = item.parentItemID; + if (!parent) { + continue; + } + + if (this._rowMap[parent] != null) { + this._closeContainer(this._rowMap[parent]); + this.toggleOpenState(this._rowMap[parent]); + this.selection.toggleSelect(this._rowMap[selection[i]]); + } + } } } + catch (e) { + Zotero.logError(e); + } + if (unsuppress) { this._treebox.endUpdateBatch(); this.selection.selectEventsSuppressed = false;