From add7bef0be852b545a9ee348ddbef6b786c4451f Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Tue, 30 Nov 2010 20:34:08 +0000 Subject: [PATCH] Show a meaningful error message when multiple instances of Zotero are open simultaneously --- chrome/content/zotero/browser.js | 8 +++----- chrome/content/zotero/overlay.js | 10 +++++----- chrome/content/zotero/xpcom/zotero.js | 6 ++++++ chrome/locale/en-US/zotero/zotero.properties | 5 ++++- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/chrome/content/zotero/browser.js b/chrome/content/zotero/browser.js index 4efe28de7..814951b94 100644 --- a/chrome/content/zotero/browser.js +++ b/chrome/content/zotero/browser.js @@ -100,17 +100,15 @@ var Zotero_Browser = new function() { ////////////////////////////////////////////////////////////////////////////// - /* - * Initialize some variables and prepare event listeners for when chrome is done - * loading + /** + * Initialize some variables and prepare event listeners for when chrome is done loading */ function init() { - if (!Zotero || !Zotero.initialized) { + if (!Zotero || !Zotero.initialized || Zotero.isStandalone) { return; } Zotero_Browser.browserData = new Object(); - Zotero_Browser._scrapePopupShowing = false; window.addEventListener("load", function(e) { Zotero_Browser.chromeLoad(e) }, false); diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index 02c07f2a2..fca59de7b 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -216,7 +216,7 @@ var ZoteroPane = new function() } if(Zotero.isStandalone) { - this.toggleDisplay(); + this.toggleDisplay(true); this.fullScreen(true); } } @@ -313,7 +313,7 @@ var ZoteroPane = new function() /* * Hides/displays the Zotero interface */ - function toggleDisplay() + function toggleDisplay(forceVisible) { if (!ZoteroPane.loaded) { if (Zotero.locked) { @@ -336,9 +336,7 @@ var ZoteroPane = new function() var isCollapsed = true; } - if (isHidden || isCollapsed) { - var makeVisible = true; - } + var makeVisible = forceVisible || isHidden || isCollapsed; // If Zotero not initialized, try to get the error handler // or load the default error page @@ -365,6 +363,8 @@ var ZoteroPane = new function() errFunc(); } else { + if(Zotero.isStandalone) window.close(); + // TODO: Add a better error page/window here with reporting // instructions // window.loadURI('chrome://zotero/content/error.xul'); diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 549e5ff9f..c4e9348e8 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -417,6 +417,12 @@ var Zotero = new function(){ Zotero.getString('startupError.checkPermissions') ]); this.startupError = msg; + } else if(e.name == "NS_ERROR_STORAGE_BUSY") { + var msg = Zotero.localeJoin([ + Zotero.getString('startupError.databaseInUse'), + Zotero.getString(Zotero.isStandalone ? 'startupError.closeFirefox' : 'startupError.closeStandalone') + ]); + this.startupError = msg; } Components.utils.reportError(e); diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties index 5e2398693..f2940c74d 100644 --- a/chrome/locale/en-US/zotero/zotero.properties +++ b/chrome/locale/en-US/zotero/zotero.properties @@ -76,7 +76,10 @@ app.standalone = Zotero Standalone app.firefox = Zotero for Firefox startupError = There was an error starting Zotero. -startupError.databaseCannotBeOpened = The Zotero database cannot be opened. +startupError.databaseInUse = Your Zotero database is currently in use. Only one instance of Zotero using the same database may be opened simultaneously at this time. +startupError.closeStandalone = If Zotero Standalone is open, please close it and restart Firefox. +startupError.closeFirefox = If Firefox with the Zotero extension is open, please close it and restart Zotero Standalone. +startupError.databaseCannotBeOpened = The Zotero database cannot be opened. startupError.checkPermissions = Make sure you have read and write permissions to all files in the Zotero data directory. startupError.zoteroVersionIsOlder = This version of Zotero is older than the version last used with your database. startupError.zoteroVersionIsOlder.upgrade = Please upgrade to the latest version from zotero.org.