From 112b6d22e8349f720a6f7c6904313969dfe31aa2 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 17 Jun 2010 06:38:03 +0000 Subject: [PATCH] closes #1598, Possible to click Insert Citation twice When the user attempts to access Integration functionality while a request is still in progress, we now bring Firefox/Zotero to the foreground. --- chrome/content/zotero/xpcom/integration.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index afdc73a45f..aa465d35f3 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -31,6 +31,7 @@ const DATA_VERSION = 3; Zotero.Integration = new function() { var _fifoFile = null; var _osascriptFile; + var _inProgress = false; this.sessions = {}; @@ -156,6 +157,13 @@ Zotero.Integration = new function() { * Executes an integration command. */ this.execCommand = function execCommand(agent, command) { + if(_inProgress) { + Zotero.Integration.activate(); + Zotero.debug("Integration: Request already in progress; not executing "+agent+" "+command); + return; + } + _inProgress = true; + // Try to load the appropriate Zotero component; otherwise display an error using the alert // service try { @@ -164,6 +172,7 @@ Zotero.Integration = new function() { var application = Components.classes[componentClass] .getService(Components.interfaces.zoteroIntegrationApplication); } catch(e) { + _inProgress = false; Zotero.Integration.activate(); Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService) @@ -176,6 +185,7 @@ Zotero.Integration = new function() { try { var integration = new Zotero.Integration.Document(application); } catch(e) { + _inProgress = false; Zotero.Integration.activate(); Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService) @@ -228,6 +238,7 @@ Zotero.Integration = new function() { } } } finally { + _inProgress = false; integration.cleanup(); } }