commit 75f4360175f84ceeefe578fad971150a3de81892
parent 0aa0966a28d01388e8c34b1896ec665f2fe4d310
Author: Simon Kornblith <simon@simonster.com>
Date: Sun, 7 Aug 2011 23:26:53 +0000
Tweak connector switching to prevent a race condition
Diffstat:
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/chrome/content/zotero/xpcom/ipc.js b/chrome/content/zotero/xpcom/ipc.js
@@ -53,6 +53,11 @@ Zotero.IPC = new function() {
switchConnectorMode(true);
} else if(msg === "lockReleased") {
Zotero.onDBLockReleased();
+ } else if(msg === "checkInitComplete") {
+ while(!Zotero.initialized) {
+ Zotero.mainThread.processNextEvent(true)
+ }
+ Zotero.IPC.broadcast("initComplete");
} else if(msg === "initComplete") {
Zotero.onInitComplete();
}
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
@@ -438,10 +438,13 @@ if(appInfo.platformVersion[0] >= 2) {
// 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).
+ 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;
}
@@ -461,9 +464,6 @@ if(appInfo.platformVersion[0] >= 2) {
observerService.notifyObservers(Zotero, "zotero-reloaded", null);
}
- // Broadcast initComplete message if desired
- if(_broadcastInitComplete) Zotero.IPC.broadcast("initComplete");
-
return true;
}
@@ -696,9 +696,6 @@ if(appInfo.platformVersion[0] >= 2) {
}
if(Zotero.closing) return false;
- // We will want to broadcast when initialization completes
- _broadcastInitComplete = true;
-
// Run a second init with haveReleasedLock = true, so that
// if we still can't acquire a DB lock, we will give up
return _initDB(true);