www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 374eefada10d254fedc61147c2467d9933ea654c
parent 2bc44dddd19d6bbaef59c5524c251d226c2bcdb2
Author: Dan Stillman <dstillman@zotero.org>
Date:   Tue,  2 Jan 2018 20:17:51 -0500

Additional try/catch to fix NS_ERROR_UNEXPECTED from tree select

Follow-up to 7cd1439928

Diffstat:
Mchrome/content/zotero/xpcom/itemTreeView.js | 37+++++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js @@ -1869,19 +1869,28 @@ Zotero.ItemTreeView.prototype.selectItem = Zotero.Promise.coroutine(function* (i // refreshed. To get around this, we wait for a select event that's triggered by // itemSelected() when it's done. let promise; - if (this.selection.selectEventsSuppressed) { - this.selection.select(row); - } - else { - promise = this.waitForSelect(); + try { + if (this.selection.selectEventsSuppressed) { + this.selection.select(row); + } + else { + promise = this.waitForSelect(); + this.selection.select(row); + } + + // If |expand|, open row if container + if (expand && this.isContainer(row) && !this.isContainerOpen(row)) { + this.toggleOpenState(row); + } this.selection.select(row); } - - // If |expand|, open row if container - if (expand && this.isContainer(row) && !this.isContainerOpen(row)) { - this.toggleOpenState(row); + // Ignore NS_ERROR_UNEXPECTED from nsITreeSelection::select(), apparently when the tree + // disappears before it's called (though I can't reproduce it): + // + // https://forums.zotero.org/discussion/comment/297039/#Comment_297039 + catch (e) { + Zotero.logError(e); } - this.selection.select(row); if (promise) { yield promise; @@ -2104,10 +2113,6 @@ Zotero.ItemTreeView.prototype.rememberSelection = function (selection) { this._treebox.beginUpdateBatch(); } - // 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) { @@ -2133,6 +2138,10 @@ Zotero.ItemTreeView.prototype.rememberSelection = function (selection) { } } } + // Ignore 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 catch (e) { Zotero.logError(e); }