commit 4fcf0c3c15c3c78f39d8ad4d872fc66c043c101e
parent d86b622c0a99037bceef382c0ec43b64c52ef9e4
Author: Dan Stillman <dstillman@zotero.org>
Date: Sun, 13 Mar 2016 20:30:24 -0400
nsITreeSelection can be 0 incorrectly even if count is 0
Diffstat:
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js
@@ -67,6 +67,9 @@ Zotero.CollectionTreeView.prototype.type = 'collection';
Object.defineProperty(Zotero.CollectionTreeView.prototype, "selectedTreeRow", {
get: function () {
+ if (!this.selection || !this.selection.count) {
+ return false;
+ }
return this.getRow(this.selection.currentIndex);
}
});
@@ -940,7 +943,7 @@ Zotero.CollectionTreeView.prototype.selectLibrary = Zotero.Promise.coroutine(fun
}
// Check if library is already selected
- if (this.selection.currentIndex != -1) {
+ if (this.selection && this.selection.count && this.selection.currentIndex != -1) {
var treeRow = this.getRow(this.selection.currentIndex);
if (treeRow.isLibrary(true) && treeRow.ref.libraryID == libraryID) {
this._treebox.ensureRowIsVisible(this.selection.currentIndex);
@@ -972,7 +975,7 @@ Zotero.CollectionTreeView.prototype.selectSearch = function (id) {
Zotero.CollectionTreeView.prototype.selectTrash = Zotero.Promise.coroutine(function* (libraryID) {
// Check if trash is already selected
- if (this.selection.currentIndex != -1) {
+ if (this.selection && this.selection.count && this.selection.currentIndex != -1) {
let itemGroup = this.getRow(this.selection.currentIndex);
if (itemGroup.isTrash() && itemGroup.ref.libraryID == libraryID) {
this._treebox.ensureRowIsVisible(this.selection.currentIndex);
@@ -1196,6 +1199,8 @@ Zotero.CollectionTreeView.prototype._expandRow = Zotero.Promise.coroutine(functi
* Returns libraryID or FALSE if not a library
*/
Zotero.CollectionTreeView.prototype.getSelectedLibraryID = function() {
+ if (!this.selection || !this.selection.count || this.selection.currentIndex == -1) return false;
+
var treeRow = this.getRow(this.selection.currentIndex);
return treeRow && treeRow.ref && treeRow.ref.libraryID !== undefined
&& treeRow.ref.libraryID;