From a9bff0e3164b5f02aa722c98e73410f9f9ca599b Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 26 Mar 2007 17:57:26 +0000 Subject: [PATCH] Restore clearSelection() call in itemTreeView.rememberSelection(), since workaround didn't fix crash Made rememberSelection() in certain notify() conditions only get called when necessary, which may or may not fix or reduce the crash, depending on where it was happening Added debug output to better tell where the crash is occurring --- chrome/content/zotero/overlay.js | 1 + chrome/content/zotero/xpcom/itemTreeView.js | 19 +++++++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index 8f8abb62c..c8d2f44d9 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -585,6 +585,7 @@ var ZoteroPane = new function() this.itemsView = new Zotero.ItemTreeView(itemgroup); this.itemsView.addCallback(_setTagScope); document.getElementById('zotero-items-tree').view = this.itemsView; + Zotero.debug('crashdebug6'); this.itemsView.selection.clearSelection(); Zotero.UnresponsiveScriptIndicator.enable(); } diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js index 830b45518..e15965138 100644 --- a/chrome/content/zotero/xpcom/itemTreeView.js +++ b/chrome/content/zotero/xpcom/itemTreeView.js @@ -400,11 +400,13 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids) this._refreshHashMap(); } - this.rememberSelection(savedSelection); - if (activeWindow) { this.selectItem(ids[0]); } + else { + Zotero.debug('crashdebug1'); + this.rememberSelection(savedSelection); + } } else { @@ -414,7 +416,7 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids) else { this._refreshHashMap(); } - + Zotero.debug('crashdebug2') this.rememberSelection(savedSelection); } @@ -610,6 +612,7 @@ Zotero.ItemTreeView.prototype.cycleHeader = function(column) this.selection.selectEventsSuppressed = true; var savedSelection = this.saveSelection(); this.sort(); + Zotero.debug('crashdebug3') this.rememberSelection(savedSelection); this.selection.selectEventsSuppressed = false; this._treebox.invalidate(); @@ -983,6 +986,7 @@ Zotero.ItemTreeView.prototype.setFilter = function(type, data) { this.rememberOpenState(savedOpenState); this.rememberFirstRow(savedFirstRow); + Zotero.debug('crashdebug4') this.rememberSelection(savedSelection); this.selection.selectEventsSuppressed = false; this._treebox.invalidate(); @@ -1062,13 +1066,8 @@ Zotero.ItemTreeView.prototype.saveSelection = function() */ Zotero.ItemTreeView.prototype.rememberSelection = function(selection) { - // clearSelection() seems to cause a crash in Firefox 2.0.0.2 - 2.0.0.3, at least - //this.selection.clearSelection(); - // So try this alternative method - this.selection.selectEventsSuppressed = true; - this.selection.select(0); - this.selection.toggleSelect(0); - this.selection.selectEventsSuppressed = false; + // DEBUG: This seems to occasionally cause a crash + this.selection.clearSelection(); for(var i=0; i < selection.length; i++) {