diff --git a/chrome/content/zotero/xpcom/ipc.js b/chrome/content/zotero/xpcom/ipc.js index 38615223f..fedd0c88d 100755 --- a/chrome/content/zotero/xpcom/ipc.js +++ b/chrome/content/zotero/xpcom/ipc.js @@ -88,7 +88,7 @@ Zotero.IPC = new function() { // Standalone sends this to the Firefox extension to let the Firefox extension // know that Standalone has fully initialized and it should pull the list of // translators - Zotero.onInitComplete(); + Zotero.initComplete(); } } } diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 6295c52be..ee2b95382 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -183,8 +183,6 @@ if(appInfo.platformVersion[0] >= 2) { // whether we are waiting for another Zotero process to release its DB lock var _waitingForDBLock = false; - // whether we are waiting for another Zotero process to initialize so we can use connector - var _waitingForInitComplete = false; /** * Maintains nsITimers to be used when Zotero.wait() completes (to reduce performance penalty @@ -422,27 +420,35 @@ if(appInfo.platformVersion[0] >= 2) { Zotero.Connector_Types.init(); if(!Zotero.isFirstLoadThisSession) { - // Wait for initComplete message if we switched to connector because standalone was - // started. This shouldn't loop indefinitely, but even if it does, it won't hang - // anything (since it will stop looping on shutdown). + // We want to get a checkInitComplete message before initializing if we switched to + // connector mode because Standalone was launched Zotero.IPC.broadcast("checkInitComplete"); - Zotero.debug("Waiting for initComplete message"); - _waitingForInitComplete = true; - while(_waitingForInitComplete && !Zotero.closing) { - Zotero.mainThread.processNextEvent(true); - } - Zotero.debug("initComplete message received"); - if(Zotero.closing) return false; + } else { + Zotero.initComplete(); } - - Zotero.Repo.init(); } else { Zotero.debug("Loading in full mode"); if(!_initFull()) return false; + Zotero.initComplete(); } + return true; + } + + /** + * Triggers events when initialization finishes + */ + this.initComplete = function() { + if(Zotero.initialized) return; this.initialized = true; + if(Zotero.isConnector) { + Zotero.Repo.init(); + } + + var observerService = Components.classes["@mozilla.org/observer-service;1"] + .getService(Components.interfaces.nsIObserverService); + if(!Zotero.isFirstLoadThisSession) { // trigger zotero-reloaded event Zotero.debug('Triggering "zotero-reloaded" event'); @@ -451,8 +457,6 @@ if(appInfo.platformVersion[0] >= 2) { Zotero.debug('Triggering "zotero-loaded" event'); observerService.notifyObservers(Zotero, "zotero-loaded", null); - - return true; } /** @@ -725,13 +729,6 @@ if(appInfo.platformVersion[0] >= 2) { } } - /** - * Called when an accessory process has been initialized to let use get data - */ - this.onInitComplete = function() { - _waitingForInitComplete = false; - } - /* * Check if a DB transaction is open and, if so, disable Zotero */