diff --git a/chrome/content/zotero/tab.js b/chrome/content/zotero/tab.js index 533d91003..2dc629748 100644 --- a/chrome/content/zotero/tab.js +++ b/chrome/content/zotero/tab.js @@ -38,6 +38,11 @@ var ZoteroTab = new function() .chromeEventHandler.ownerDocument.defaultView; if(!this.containerWindow) return; + if(this.containerWindow.ZoteroPane && this.containerWindow.ZoteroPane.itemsView) { + this.containerWindow.ZoteroPane.itemsView.unregister(); + delete this.containerWindow.ZoteroPane.itemsView; + } + var tabs = (this.containerWindow.gBrowser.tabs ? this.containerWindow.gBrowser.tabs : this.containerWindow.gBrowser.mTabs); diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js index d38f1177e..bca57e776 100644 --- a/chrome/content/zotero/xpcom/itemTreeView.js +++ b/chrome/content/zotero/xpcom/itemTreeView.js @@ -304,11 +304,8 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData) this.selection.selectEventsSuppressed = true; // See if we're in the active window - var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] - .getService(Components.interfaces.nsIWindowMediator); - if (wm.getMostRecentWindow("navigator:browser") == this._ownerDocument.defaultView){ - var activeWindow = true; - } + var zp = Zotero.getActiveZoteroPane(); + var activeWindow = zp && zp.itemsView == this; var quicksearch = this._ownerDocument.getElementById('zotero-tb-search'); @@ -1537,21 +1534,7 @@ Zotero.ItemTreeView.prototype.saveSelection = function() * Sets the selection based on saved selection ids (see above) */ Zotero.ItemTreeView.prototype.rememberSelection = function(selection) -{ - // if itemRowMap not yet defined, remember once it is - if(!this._itemRowMap) { - var me = this; - var callback = function() { - // remember selection - me.rememberSelection(selection); - - // remove callback - me._callbacks.splice(me._callbacks.indexOf(callback), 1); - } - this.addCallback(callback); - return; - } - +{ this.selection.clearSelection(); for(var i=0; i < selection.length; i++) diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 3faaf8b02..01b33fb4f 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -310,7 +310,9 @@ var ZoteroPane = new function() return; } - this.serializePersist(); + if(this.isShowing()) { + this.serializePersist(); + } var tagSelector = document.getElementById('zotero-tag-selector'); tagSelector.unregister(); @@ -349,9 +351,14 @@ var ZoteroPane = new function() var containerWindow = (window.ZoteroTab ? window.ZoteroTab.containerWindow : window); if(containerWindow.zoteroSavedSelection) { - Zotero.debug("ZoteroPane: Remembering selection"); - this.itemsView.rememberSelection(containerWindow.zoteroSavedSelection); - delete containerWindow.zoteroSavedSelection; + var me = this; + // hack to restore saved selection after itemTreeView finishes loading + window.setTimeout(function() { + if(containerWindow.zoteroSavedSelection) { + me.itemsView.rememberSelection(containerWindow.zoteroSavedSelection) + delete containerWindow.zoteroSavedSelection; + } + }, 51); } this.updateTagSelectorSize();