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.
This commit is contained in:
parent
fa33eb72b2
commit
7cd1439928
1 changed files with 30 additions and 20 deletions
|
@ -2103,30 +2103,40 @@ Zotero.ItemTreeView.prototype.rememberSelection = function (selection) {
|
||||||
var unsuppress = this.selection.selectEventsSuppressed = true;
|
var unsuppress = this.selection.selectEventsSuppressed = true;
|
||||||
this._treebox.beginUpdateBatch();
|
this._treebox.beginUpdateBatch();
|
||||||
}
|
}
|
||||||
for(var i=0; i < selection.length; i++)
|
|
||||||
{
|
// Use try/catch to work around NS_ERROR_UNEXPECTED from nsITreeSelection::toggleSelect(),
|
||||||
if (this._rowMap[selection[i]] != null) {
|
// apparently when the tree disappears before it's called (though I can't reproduce it):
|
||||||
this.selection.toggleSelect(this._rowMap[selection[i]]);
|
//
|
||||||
}
|
// https://forums.zotero.org/discussion/69226/papers-become-invisible-in-the-middle-pane
|
||||||
// Try the parent
|
try {
|
||||||
else {
|
for (let i = 0; i < selection.length; i++) {
|
||||||
var item = Zotero.Items.get(selection[i]);
|
if (this._rowMap[selection[i]] != null) {
|
||||||
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]]);
|
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) {
|
if (unsuppress) {
|
||||||
this._treebox.endUpdateBatch();
|
this._treebox.endUpdateBatch();
|
||||||
this.selection.selectEventsSuppressed = false;
|
this.selection.selectEventsSuppressed = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue