commit 2e0d6aa4ec1ce8840ac6eb652db039114c28eeb7
parent 3c1bb02c9f539537e4200934bc641735f97d86b2
Author: Simon Kornblith <simon@simonster.com>
Date: Tue, 1 Mar 2011 05:31:20 +0000
make Zotero.Integration.execCommand() synchronous on Fx 4
Diffstat:
1 file changed, 28 insertions(+), 26 deletions(-)
diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js
@@ -130,30 +130,6 @@ Zotero.Integration = new function() {
* Executes an integration command, first checking to make sure that versions are compatible
*/
this.execCommand = function execCommand(agent, command, docId) {
- var verComp = Components.classes["@mozilla.org/xpcom/version-comparator;1"]
- .getService(Components.interfaces.nsIVersionComparator);
- function _checkAddons(addons) {
- for each(var addon in addons) {
- if(!addon) continue;
-
- if(verComp.compare(INTEGRATION_MIN_VERSION, addon.version) > 0) {
- _inProgress = false;
- _integrationVersionsOK = false;
- Zotero.Integration.activate();
- var msg = Zotero.getString(
- "integration.error.incompatibleVersion2",
- [Zotero.version, addon.name, INTEGRATION_MIN_VERSION]
- );
- Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService)
- .alert(null, Zotero.getString("integration.error.title"), msg);
- throw msg;
- }
- }
- _integrationVersionsOK = true;
- _callIntegration(agent, command, docId);
- }
-
if(_inProgress) {
Zotero.Integration.activate();
Zotero.debug("Integration: Request already in progress; not executing "+agent+" "+command);
@@ -163,9 +139,36 @@ Zotero.Integration = new function() {
// Check integration component versions
if(!_integrationVersionsOK) {
+ var verComp = Components.classes["@mozilla.org/xpcom/version-comparator;1"]
+ .getService(Components.interfaces.nsIVersionComparator);
+ var addonsChecked = false;
+ function _checkAddons(addons) {
+ addonsChecked = true;
+ for each(var addon in addons) {
+ if(!addon) continue;
+
+ if(verComp.compare(INTEGRATION_MIN_VERSION, addon.version) > 0) {
+ _inProgress = false;
+ _integrationVersionsOK = false;
+ Zotero.Integration.activate();
+ var msg = Zotero.getString(
+ "integration.error.incompatibleVersion2",
+ [Zotero.version, addon.name, INTEGRATION_MIN_VERSION]
+ );
+ Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService)
+ .alert(null, Zotero.getString("integration.error.title"), msg);
+ throw msg;
+ }
+ }
+ _integrationVersionsOK = true;
+ _callIntegration(agent, command, docId);
+ }
+
if(Zotero.isFx4) {
Components.utils.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAddonsByIDs(INTEGRATION_PLUGINS, _checkAddons);
+ while(!addonsChecked) Zotero.mainThread.processNextEvent(true);
} else {
var extMan = Components.classes['@mozilla.org/extensions/manager;1'].
getService(Components.interfaces.nsIExtensionManager);
@@ -2107,4 +2110,4 @@ Zotero.Integration.URIMap.prototype.getZoteroItemForURIs = function(uris) {
}
return [zoteroItem, needUpdate];
-}
-\ No newline at end of file
+}