Fixes #1844, Fix connector switching hangs with Firefox 3.6 on Windows. Standalone will just take an extra 5 seconds to start if started while Firefox 3.6 is running.
This commit is contained in:
parent
67c81db102
commit
8638b9c496
|
@ -175,6 +175,11 @@ if(appInfo.platformVersion[0] >= 2) {
|
||||||
*/
|
*/
|
||||||
this.suppressUIUpdates = false;
|
this.suppressUIUpdates = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property {Boolean} closing True if the application is closing.
|
||||||
|
*/
|
||||||
|
this.closing = false;
|
||||||
|
|
||||||
var _startupErrorHandler;
|
var _startupErrorHandler;
|
||||||
var _zoteroDirectory = false;
|
var _zoteroDirectory = false;
|
||||||
var _localizedStringBundle;
|
var _localizedStringBundle;
|
||||||
|
@ -420,6 +425,15 @@ if(appInfo.platformVersion[0] >= 2) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register shutdown handler to call Zotero.shutdown()
|
||||||
|
var _shutdownObserver = {observe:Zotero.shutdown};
|
||||||
|
observerService.addObserver(_shutdownObserver, "quit-application", false);
|
||||||
|
|
||||||
|
// Add shutdown listerner to remove observer
|
||||||
|
this.addShutdownListener(function() {
|
||||||
|
observerService.removeObserver(_shutdownObserver, "quit-application", false);
|
||||||
|
});
|
||||||
|
|
||||||
Zotero.IPC.init();
|
Zotero.IPC.init();
|
||||||
|
|
||||||
// Load additional info for connector or not
|
// Load additional info for connector or not
|
||||||
|
@ -428,10 +442,14 @@ if(appInfo.platformVersion[0] >= 2) {
|
||||||
Zotero.Connector_Types.init();
|
Zotero.Connector_Types.init();
|
||||||
|
|
||||||
if(!Zotero.isFirstLoadThisSession) {
|
if(!Zotero.isFirstLoadThisSession) {
|
||||||
// wait for initComplete message if we switched to connector because standalone was
|
// Wait for initComplete message if we switched to connector because standalone was
|
||||||
// started
|
// started. This shouldn't loop indefinitely, but even if it does, it won't hang
|
||||||
|
// anything (since it will stop looping on shutdown).
|
||||||
_waitingForInitComplete = true;
|
_waitingForInitComplete = true;
|
||||||
while(_waitingForInitComplete) Zotero.mainThread.processNextEvent(true);
|
while(_waitingForInitComplete && !Zotero.closing) {
|
||||||
|
Zotero.mainThread.processNextEvent(true);
|
||||||
|
}
|
||||||
|
if(Zotero.closing) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Zotero.Repo.init();
|
Zotero.Repo.init();
|
||||||
|
@ -442,15 +460,6 @@ if(appInfo.platformVersion[0] >= 2) {
|
||||||
|
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
|
|
||||||
// Register shutdown handler to call Zotero.shutdown()
|
|
||||||
var _shutdownObserver = {observe:Zotero.shutdown};
|
|
||||||
observerService.addObserver(_shutdownObserver, "quit-application", false);
|
|
||||||
|
|
||||||
// Add shutdown listerner to remove observer
|
|
||||||
this.addShutdownListener(function() {
|
|
||||||
observerService.removeObserver(_shutdownObserver, "quit-application", false);
|
|
||||||
});
|
|
||||||
|
|
||||||
Zotero.debug("Initialized in "+((new Date()).getTime() - start)+" ms");
|
Zotero.debug("Initialized in "+((new Date()).getTime() - start)+" ms");
|
||||||
|
|
||||||
if(!Zotero.isFirstLoadThisSession) {
|
if(!Zotero.isFirstLoadThisSession) {
|
||||||
|
@ -645,7 +654,7 @@ if(appInfo.platformVersion[0] >= 2) {
|
||||||
/**
|
/**
|
||||||
* Initializes the DB connection
|
* Initializes the DB connection
|
||||||
*/
|
*/
|
||||||
function _initDB() {
|
function _initDB(haveReleasedLock) {
|
||||||
try {
|
try {
|
||||||
// Test read access
|
// Test read access
|
||||||
Zotero.DB.test();
|
Zotero.DB.test();
|
||||||
|
@ -685,12 +694,21 @@ if(appInfo.platformVersion[0] >= 2) {
|
||||||
} else if(e.name == "NS_ERROR_STORAGE_BUSY" || e.result == 2153971713) {
|
} else if(e.name == "NS_ERROR_STORAGE_BUSY" || e.result == 2153971713) {
|
||||||
if(Zotero.isStandalone) {
|
if(Zotero.isStandalone) {
|
||||||
// Standalone should force Fx to release lock
|
// Standalone should force Fx to release lock
|
||||||
if(Zotero.IPC.broadcast("releaseLock")) {
|
if(!haveReleasedLock && Zotero.IPC.broadcast("releaseLock")) {
|
||||||
_waitingForDBLock = true;
|
_waitingForDBLock = true;
|
||||||
while(_waitingForDBLock) Zotero.mainThread.processNextEvent(true);
|
|
||||||
// we will want to broadcast when initialization completes
|
var timeout = Date.now() + 5000; // 5 second timeout
|
||||||
|
while(_waitingForDBLock && !Zotero.closing && Date.now() < timeout) {
|
||||||
|
Zotero.mainThread.processNextEvent(true);
|
||||||
|
}
|
||||||
|
if(Zotero.closing) return;
|
||||||
|
|
||||||
|
// We will want to broadcast when initialization completes
|
||||||
_broadcastInitComplete = true;
|
_broadcastInitComplete = true;
|
||||||
return _initDB();
|
|
||||||
|
// 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);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Fx should start as connector if Standalone is running
|
// Fx should start as connector if Standalone is running
|
||||||
|
@ -754,6 +772,9 @@ if(appInfo.platformVersion[0] >= 2) {
|
||||||
Zotero.debug("Shutting down Zotero");
|
Zotero.debug("Shutting down Zotero");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// set closing to true
|
||||||
|
Zotero.closing = true;
|
||||||
|
|
||||||
// run shutdown listener
|
// run shutdown listener
|
||||||
for each(var listener in _shutdownListeners) listener();
|
for each(var listener in _shutdownListeners) listener();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user