mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 10:27:58 +01:00
Fix config.addon race and add guards against future breakage.
This commit is contained in:
2
common/bootstrap.js
vendored
2
common/bootstrap.js
vendored
@@ -79,7 +79,9 @@ function startup(data, reason) {
|
||||
|
||||
addonData = data;
|
||||
addon = data;
|
||||
dump("dactyl: bootstrap: pre-getAddonByID\n");
|
||||
AddonManager.getAddonByID(addon.id, function (a) {
|
||||
dump("dactyl: bootstrap: getAddonByID: " + a + "\n");
|
||||
addon = a;
|
||||
updateVersion();
|
||||
});
|
||||
|
||||
@@ -232,6 +232,24 @@ var Addon = Class("Addon", {
|
||||
}
|
||||
});
|
||||
|
||||
["cancelUninstall", "findUpdates", "getResourceURI", "hasResource", "isCompatibleWith",
|
||||
"uninstall"].forEach(function (prop) {
|
||||
Addon.prototype[prop] = function proxy() this.addon[prop].apply(this.addon, arguments);
|
||||
});
|
||||
|
||||
["aboutURL", "appDisabled", "applyBackgroundUpdates", "blocklistState", "contributors", "creator",
|
||||
"description", "developers", "homepageURL", "iconURL", "id", "install", "installDate", "isActive",
|
||||
"isCompatible", "isPlatformCompatible", "name", "operationsRequiringRestart", "optionsURL",
|
||||
"pendingOperations", "pendingUpgrade", "permissions", "providesUpdatesSecurely", "releaseNotesURI",
|
||||
"scope", "screenshots", "size", "sourceURI", "translators", "type", "updateDate", "userDisabled",
|
||||
"version"].forEach(function (prop) {
|
||||
Object.defineProperty(Addon.prototype, prop, {
|
||||
get: function get_proxy() this.addon[prop],
|
||||
set: function set_proxy(val) this.addon[prop] = val
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
var AddonList = Class("AddonList", {
|
||||
init: function init(modules, types, filter) {
|
||||
this.modules = modules;
|
||||
@@ -561,24 +579,6 @@ var addonErrors = array.toObject([
|
||||
|
||||
endModule();
|
||||
|
||||
let iterator = properties(config.addon);
|
||||
if ("nsIUpdateItem" in Ci)
|
||||
iterator = iter(iterator, properties(config.addon.__proto__));
|
||||
|
||||
iter.forEach(iterator, function (prop) {
|
||||
let desc = Object.getOwnPropertyDescriptor(config.addon, prop) ||
|
||||
Object.getOwnPropertyDescriptor(config.addon.__proto__, prop);
|
||||
|
||||
if (!set.has(Addon.prototype, prop))
|
||||
if (callable(desc.value))
|
||||
Addon.prototype[prop] = function proxy() this.addon[prop].apply(this.addon, arguments);
|
||||
else
|
||||
Object.defineProperty(Addon.prototype, prop, {
|
||||
get: function get_proxy() this.addon[prop],
|
||||
set: function set_proxy(val) this.addon[prop] = val
|
||||
});
|
||||
});
|
||||
|
||||
} catch(e){ if (isString(e)) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); }
|
||||
|
||||
// vim: set fdm=marker sw=4 ts=4 et ft=javascript:
|
||||
|
||||
@@ -53,7 +53,15 @@ var ConfigBase = Class("ConfigBase", {
|
||||
|
||||
get addonID() this.name + "@dactyl.googlecode.com",
|
||||
addon: Class.memoize(function () {
|
||||
let addon = services.fuel.storage.get("dactyl.bootstrap", {}).addon;
|
||||
let addon;
|
||||
util.waitFor(function () {
|
||||
addon = services.fuel.storage.get("dactyl.bootstrap", {}).addon;
|
||||
if (addon && !addon.getResourceURI)
|
||||
util.reportError(Error("Don't have add-on yet"));
|
||||
|
||||
return !addon || addon.getResourceURI();
|
||||
});
|
||||
|
||||
if (!addon)
|
||||
addon = require("addons").AddonManager.getAddonByID(this.addonID);
|
||||
return addon;
|
||||
|
||||
Reference in New Issue
Block a user