1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-24 09:32:28 +01:00

[bootstrap] Minor fixes.

--HG--
branch : bootstrapped
This commit is contained in:
Kris Maglione
2010-12-24 20:37:39 -05:00
parent adeb5f7dd2
commit d0b5a5b209
4 changed files with 37 additions and 28 deletions

View File

@@ -13,20 +13,21 @@ plugins.contexts = {};
function Script(file) {
let self = set.has(plugins, file.path) && plugins[file.path];
if (self) {
if (self.onUnload)
if (set.has(self, "onUnload"))
self.onUnload();
}
else {
self = { __proto__: plugins };
plugins[file.path] = self;
self.NAME = file.leafName.replace(/\..*/, "").replace(/-([a-z])/g, function (m, n1) n1.toUpperCase());
self.PATH = file.path;
self.CONTEXT = self;
self = update({ __proto__: plugins }, {
NAME: file.leafName.replace(/\..*/, "").replace(/-([a-z])/g, function (m, n1) n1.toUpperCase()),
PATH: file.path,
CONTEXT: self
});
Class.replaceProperty(plugins, file.path, self);
// This belongs elsewhere
if (io.getRuntimeDirectories("plugins").some(
function (dir) dir.contains(file, false)))
plugins[self.NAME] = self;
Class.replaceProperty(plugins, self.NAME, self);
}
plugins.contexts[file.path] = self;
return self;
@@ -67,6 +68,13 @@ const IO = Module("io", {
services.downloadManager.addListener(this.downloadListener);
},
destroy: function () {
services.downloadManager.removeListener(this.downloadListener);
for (let [, plugin] in Iterator(plugins.contexts))
if (plugin.onUnload)
plugin.onUnload();
},
// TODO: there seems to be no way, short of a new component, to change
// the process's CWD - see https://bugzilla.mozilla.org/show_bug.cgi?id=280953
/**
@@ -111,13 +119,6 @@ const IO = Module("io", {
return this.cwd;
},
destroy: function () {
services.downloadManager.removeListener(this.downloadListener);
for (let [, plugin] in Iterator(plugins.contexts))
if (plugin.onUnload)
plugin.onUnload();
},
/**
* @property {function} File class.
* @final