1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 08:07:58 +01:00

Fix some more bootstrapping update bugs.

This commit is contained in:
Kris Maglione
2011-01-17 21:40:54 -05:00
parent 41441f600c
commit 35419ad234
7 changed files with 61 additions and 32 deletions

12
common/bootstrap.js vendored
View File

@@ -65,8 +65,7 @@ function startup(data, reason) {
init(); init();
} }
catch (e) { catch (e) {
dump("dactyl: bootstrap: " + e + "\n" + e.stack); reportError(e);
Cu.reportError(e);
} }
} }
} }
@@ -130,10 +129,15 @@ function init() {
} }
} }
dump("JSMLoader " + (typeof JSMLoader !== "undefined" && JSMLoader.bump) + "\n"); if (JSMLoader && JSMLoader.bump != 3) // Temporary hack
if (typeof JSMLoader === "undefined" || JSMLoader.bump != 2) Services.scriptloader.loadSubScript("resource://dactyl" + suffix + "/bootstrap.jsm",
Cu.import("resource://dactyl/bootstrap.jsm", global));
if (!JSMLoader || JSMLoader.bump != 3)
Cu.import("resource://dactyl/bootstrap.jsm", global); Cu.import("resource://dactyl/bootstrap.jsm", global);
JSMLoader.load("resource://dactyl/bootstrap.jsm", global);
JSMLoader.init(suffix); JSMLoader.init(suffix);
JSMLoader.load("base.jsm", global); JSMLoader.load("base.jsm", global);

View File

@@ -115,8 +115,6 @@ function Dactyl() {
this.pages = {}; this.pages = {};
Cu.import("resource://dactyl/bootstrap.jsm");
JSMLoader.init();
JSMLoader.load("base.jsm", global); JSMLoader.load("base.jsm", global);
require(global, "config"); require(global, "config");
require(global, "services"); require(global, "services");
@@ -194,6 +192,7 @@ Dactyl.prototype = {
observe: function observe(subject, topic, data) { observe: function observe(subject, topic, data) {
if (topic === "profile-after-change") { if (topic === "profile-after-change") {
Cu.import("resource://dactyl/bootstrap.jsm"); Cu.import("resource://dactyl/bootstrap.jsm");
JSMLoader.init();
require(global, "overlay"); require(global, "overlay");
} }
} }

View File

@@ -1575,6 +1575,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
function listener(action, event) function listener(action, event)
function addonListener(install) { function addonListener(install) {
if (typeof dactyl !== "undefined")
dactyl[install.error ? "echoerr" : "echomsg"]( dactyl[install.error ? "echoerr" : "echomsg"](
"Add-on " + action + " " + event + ": " + (install.name || install.sourceURI.spec) + "Add-on " + action + " " + event + ": " + (install.name || install.sourceURI.spec) +
(install.error ? ": " + addonErrors[install.error] : "")); (install.error ? ": " + addonErrors[install.error] : ""));

View File

@@ -964,7 +964,8 @@ var Timer = Class("Timer", {
}, },
notify: function (timer) { notify: function (timer) {
if (util.rehashing) try {
if (util.rehashing || typeof util === "undefined")
return; return;
this._timer.cancel(); this._timer.cancel();
@@ -972,9 +973,14 @@ var Timer = Class("Timer", {
// minInterval is the time between the completion of the command and the next firing // minInterval is the time between the completion of the command and the next firing
this.doneAt = Date.now() + this.minInterval; this.doneAt = Date.now() + this.minInterval;
try {
this.callback(this.arg); this.callback(this.arg);
} }
catch (e) {
if (typeof util === "undefined")
dump("dactyl: " + e + "\n" + (e.stack || Error().stack));
else
util.reportError(e);
}
finally { finally {
this.doneAt = Date.now() + this.minInterval; this.doneAt = Date.now() + this.minInterval;
} }

View File

@@ -4,29 +4,33 @@
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
"use strict"; "use strict";
var EXPORTED_SYMBOLS = ["JSMLoader"];
let global = this;
try { try {
if (!JSMLoader || JSMLoader.bump != 2) var EXPORTED_SYMBOLS = ["JSMLoader"];
var JSMLoader = { var global = this;
bump: 2, var storage = Components.classes["@mozilla.org/fuel/application;1"]
.getService(Components.interfaces.fuelIApplication)
.storage;
var JSMLoader = storage.get("dactyl.JSMLoader", undefined);
if (!JSMLoader || JSMLoader.bump != 3)
JSMLoader = {
bump: 3,
builtin: Components.utils.Sandbox(this), builtin: Components.utils.Sandbox(this),
canonical: {}, canonical: {},
factories: [], factories: [],
globals: {}, globals: JSMLoader ? JSMLoader.globals : {},
io: Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService), io: Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService),
loader: Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader), loader: Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader),
manager: Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar), manager: Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar),
stale: {}, stale: JSMLoader ? JSMLoader.stale : {},
storage: storage,
suffix: "", suffix: "",
init: function init(suffix) { init: function init(suffix) {
this.suffix = suffix || ""; this.suffix = suffix || "";
Components.classes["@mozilla.org/fuel/application;1"] this.storage.set("dactyl.JSMLoader", this);
.getService(Components.interfaces.fuelIApplication)
.storage.set("dactyl.JSMLoader", this);
let base = JSMLoader.load("base.jsm", global); let base = JSMLoader.load("base.jsm", global);
global.EXPORTED_SYMBOLS = base.EXPORTED_SYMBOLS; global.EXPORTED_SYMBOLS = base.EXPORTED_SYMBOLS;
@@ -52,9 +56,11 @@ if (!JSMLoader || JSMLoader.bump != 2)
delete this.stale[name]; delete this.stale[name];
delete this.stale[targetURL]; delete this.stale[targetURL];
let loadURL = url.replace(RegExp("^(resource://dactyl)/"), "$1" + this.suffix + "/");
let global = this.globals[name]; let global = this.globals[name];
if (stale === targetURL) if (stale === targetURL)
this.loadSubScript(url, global.global || global); this.loadSubScript(loadURL, global.global || global);
} }
try { try {
@@ -72,7 +78,12 @@ if (!JSMLoader || JSMLoader.bump != 2)
this.manager.unregisterFactory(factory.classID, factory); this.manager.unregisterFactory(factory.classID, factory);
}, },
purge: function purge() { purge: function purge() {
dump("dactyl: JSMLoader: purge\n");
for (let [url, global] in Iterator(this.globals)) { for (let [url, global] in Iterator(this.globals)) {
if (url === "bootstrap.jsm" || url === "resource://dactyl/bootstrap.jsm")
continue;
let target = this.getTarget(url); let target = this.getTarget(url);
this.stale[url] = target; this.stale[url] = target;
this.stale[target] = target; this.stale[target] = target;

View File

@@ -4,6 +4,8 @@
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
"use strict"; "use strict";
try {
Components.utils.import("resource://dactyl/bootstrap.jsm"); Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("overlay", { defineModule("overlay", {
exports: ["ModuleBase"], exports: ["ModuleBase"],
@@ -276,4 +278,6 @@ var Overlay = Module("Overlay", {
} }
}); });
} catch(e){ if (!e.stack) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); }
// vim: set fdm=marker sw=4 ts=4 et ft=javascript: // vim: set fdm=marker sw=4 ts=4 et ft=javascript:

View File

@@ -152,8 +152,11 @@ var Storage = Module("Storage", {
}, },
cleanup: function () { cleanup: function () {
for (let key in keys(this.keys)) for (let key in keys(this.keys)) {
if (this[key].timer)
this[key].timer.flush();
delete this[key]; delete this[key];
}
for (let ary in values(this.observers)) for (let ary in values(this.observers))
for (let obj in values(ary)) for (let obj in values(ary))
if (obj.ref && obj.ref.get()) if (obj.ref && obj.ref.get())
@@ -239,6 +242,7 @@ var Storage = Module("Storage", {
}, },
save: function save(key) { save: function save(key) {
if (this[key])
saveData(this.keys[key]); saveData(this.keys[key]);
}, },