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
This commit is contained in:
Dan Stillman 2007-03-26 17:57:26 +00:00
parent 8fff3ddad2
commit a9bff0e316
2 changed files with 10 additions and 10 deletions

View File

@ -585,6 +585,7 @@ var ZoteroPane = new function()
this.itemsView = new Zotero.ItemTreeView(itemgroup); this.itemsView = new Zotero.ItemTreeView(itemgroup);
this.itemsView.addCallback(_setTagScope); this.itemsView.addCallback(_setTagScope);
document.getElementById('zotero-items-tree').view = this.itemsView; document.getElementById('zotero-items-tree').view = this.itemsView;
Zotero.debug('crashdebug6');
this.itemsView.selection.clearSelection(); this.itemsView.selection.clearSelection();
Zotero.UnresponsiveScriptIndicator.enable(); Zotero.UnresponsiveScriptIndicator.enable();
} }

View File

@ -400,11 +400,13 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids)
this._refreshHashMap(); this._refreshHashMap();
} }
this.rememberSelection(savedSelection);
if (activeWindow) { if (activeWindow) {
this.selectItem(ids[0]); this.selectItem(ids[0]);
} }
else {
Zotero.debug('crashdebug1');
this.rememberSelection(savedSelection);
}
} }
else else
{ {
@ -414,7 +416,7 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids)
else { else {
this._refreshHashMap(); this._refreshHashMap();
} }
Zotero.debug('crashdebug2')
this.rememberSelection(savedSelection); this.rememberSelection(savedSelection);
} }
@ -610,6 +612,7 @@ Zotero.ItemTreeView.prototype.cycleHeader = function(column)
this.selection.selectEventsSuppressed = true; this.selection.selectEventsSuppressed = true;
var savedSelection = this.saveSelection(); var savedSelection = this.saveSelection();
this.sort(); this.sort();
Zotero.debug('crashdebug3')
this.rememberSelection(savedSelection); this.rememberSelection(savedSelection);
this.selection.selectEventsSuppressed = false; this.selection.selectEventsSuppressed = false;
this._treebox.invalidate(); this._treebox.invalidate();
@ -983,6 +986,7 @@ Zotero.ItemTreeView.prototype.setFilter = function(type, data) {
this.rememberOpenState(savedOpenState); this.rememberOpenState(savedOpenState);
this.rememberFirstRow(savedFirstRow); this.rememberFirstRow(savedFirstRow);
Zotero.debug('crashdebug4')
this.rememberSelection(savedSelection); this.rememberSelection(savedSelection);
this.selection.selectEventsSuppressed = false; this.selection.selectEventsSuppressed = false;
this._treebox.invalidate(); this._treebox.invalidate();
@ -1062,13 +1066,8 @@ Zotero.ItemTreeView.prototype.saveSelection = function()
*/ */
Zotero.ItemTreeView.prototype.rememberSelection = function(selection) Zotero.ItemTreeView.prototype.rememberSelection = function(selection)
{ {
// clearSelection() seems to cause a crash in Firefox 2.0.0.2 - 2.0.0.3, at least // DEBUG: This seems to occasionally cause a crash
//this.selection.clearSelection(); this.selection.clearSelection();
// So try this alternative method
this.selection.selectEventsSuppressed = true;
this.selection.select(0);
this.selection.toggleSelect(0);
this.selection.selectEventsSuppressed = false;
for(var i=0; i < selection.length; i++) for(var i=0; i < selection.length; i++)
{ {