commit 91024eb87cdd427fc530571259ce95f0d01d4378
parent 9ce0e47117e2fc0bb4a64fa60a4d9e6b21a987e2
Author: Simon Kornblith <simon@simonster.com>
Date: Tue, 16 Aug 2011 18:28:55 +0000
- Prevent a deadlock when Zotero.wait() was called during initialization
- Don't spin Zotero.mainThread.processNextEvent() forever when translator could not be retrieved
Diffstat:
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/chrome/content/zotero/xpcom/ipc.js b/chrome/content/zotero/xpcom/ipc.js
@@ -73,10 +73,17 @@ Zotero.IPC = new function() {
} else if(msg === "checkInitComplete") {
// The Firefox extension sends this to Standalone to tell Standalone to send an
// initComplete message when it is fully initialized
- while(!Zotero.initialized) {
- Zotero.mainThread.processNextEvent(true)
+ if(Zotero.initialized) {
+ Zotero.IPC.broadcast("initComplete");
+ } else {
+ var observerService = Components.classes["@mozilla.org/observer-service;1"]
+ .getService(Components.interfaces.nsIObserverService);
+ var _loadObserver = function() {
+ Zotero.IPC.broadcast("initComplete");
+ observerService.removeObserver(_loadObserver, "zotero-loaded");
+ };
+ observerService.addObserver(_loadObserver, "zotero-loaded", false);
}
- Zotero.IPC.broadcast("initComplete");
} else if(msg === "initComplete") {
// 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
diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js
@@ -349,7 +349,7 @@ Zotero.Translate.Sandbox = {
Zotero.Translators.get(translation.translator[0], haveTranslatorFunction);
if(Zotero.isConnector && Zotero.isFx && !callback) {
- while(!sandbox) {
+ while(!sandbox && translate._currentState) {
Zotero.mainThread.processNextEvent(true);
}
}
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
@@ -459,6 +459,9 @@ if(appInfo.platformVersion[0] >= 2) {
observerService.notifyObservers(Zotero, "zotero-reloaded", null);
}
+ Zotero.debug('Triggering "zotero-loaded" event');
+ observerService.notifyObservers(Zotero, "zotero-loaded", null);
+
return true;
}