Eliminate processNextEvent call

This commit is contained in:
Simon Kornblith 2011-09-20 19:28:05 +00:00
parent fb46cf23de
commit f3a64939ed

View File

@ -102,7 +102,7 @@ Zotero.Integration = new function() {
_updateTimer = Components.classes["@mozilla.org/timer;1"]. _updateTimer = Components.classes["@mozilla.org/timer;1"].
createInstance(Components.interfaces.nsITimer); createInstance(Components.interfaces.nsITimer);
_updateTimer.initWithCallback({"notify":_checkPluginVersions}, 1000, _updateTimer.initWithCallback({"notify":function() { _checkPluginVersions() }}, 1000,
Components.interfaces.nsITimer.TYPE_ONE_SHOT); Components.interfaces.nsITimer.TYPE_ONE_SHOT);
} }
@ -142,9 +142,14 @@ Zotero.Integration = new function() {
} }
} }
function _checkPluginVersions() { function _checkPluginVersions(callback) {
if(_updateTimer) _updateTimer = undefined; if(_updateTimer) _updateTimer = undefined;
if(_integrationVersionsOK !== null) {
if(callback) callback(_integrationVersionsOK);
return;
}
var verComp = Components.classes["@mozilla.org/xpcom/version-comparator;1"] var verComp = Components.classes["@mozilla.org/xpcom/version-comparator;1"]
.getService(Components.interfaces.nsIVersionComparator); .getService(Components.interfaces.nsIVersionComparator);
var addonsChecked = false; var addonsChecked = false;
@ -166,24 +171,22 @@ Zotero.Integration = new function() {
Components.classes["@mozilla.org/embedcomp/prompt-service;1"] Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService) .getService(Components.interfaces.nsIPromptService)
.alert(null, Zotero.getString("integration.error.title"), msg); .alert(null, Zotero.getString("integration.error.title"), msg);
success = false;
throw msg; throw msg;
} }
} }
_integrationVersionsOK = true; _integrationVersionsOK = true;
if(callback) callback(_integrationVersionsOK);
} }
if(Zotero.isFx4) { if(Zotero.isFx4) {
Components.utils.import("resource://gre/modules/AddonManager.jsm"); Components.utils.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAddonsByIDs(INTEGRATION_PLUGINS, _checkAddons); AddonManager.getAddonsByIDs(INTEGRATION_PLUGINS, _checkAddons);
while(!addonsChecked) Zotero.mainThread.processNextEvent(true);
} else { } else {
var extMan = Components.classes['@mozilla.org/extensions/manager;1']. var extMan = Components.classes['@mozilla.org/extensions/manager;1'].
getService(Components.interfaces.nsIExtensionManager); getService(Components.interfaces.nsIExtensionManager);
_checkAddons([extMan.getItemForID(id) for each(id in INTEGRATION_PLUGINS)]); _checkAddons([extMan.getItemForID(id) for each(id in INTEGRATION_PLUGINS)]);
} }
return success;
} }
/** /**
@ -201,11 +204,13 @@ Zotero.Integration = new function() {
_inProgress = true; _inProgress = true;
// Check integration component versions // Check integration component versions
if(_checkPluginVersions()) { _checkPluginVersions(function(success) {
_callIntegration(agent, command, docId); if(success) {
} else { _callIntegration(agent, command, docId);
_inProgress = false; } else {
} _inProgress = false;
}
});
} }
/** /**