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

Prevent infinite loops when trying to execute mappings recursively.

This commit is contained in:
Kris Maglione
2011-01-18 18:09:28 -05:00
parent c78bb0f332
commit b836cc8110
4 changed files with 15 additions and 9 deletions

View File

@@ -1018,6 +1018,7 @@ var Events = Module("events", {
if (refeed)
for (let [i, event] in Iterator(refeed))
if (event.originalTarget) {
util.dump("Re-feed " + i + " " + refeed.length + " " + (events.toString(event) || "").quote());
let evt = events.create(event.originalTarget.ownerDocument, event.type, event);
events.dispatch(event.originalTarget, evt, i == 0 && { skipmap: true });
}

View File

@@ -110,7 +110,11 @@ var Map = Class("Map", {
if (this.names[0] != ".") // FIXME: Kludge.
mappings.repeat = repeat;
return dactyl.trapErrors(repeat);
dactyl.assert(!this.executing, "Attempt to execute mapping recursively");
this.executing = true;
let res = dactyl.trapErrors(repeat);
this.executing = false;
return res;
}
}, {

View File

@@ -387,7 +387,7 @@ var Modes = Module("modes", {
}, options);
},
toString: function () this.name,
get toStringParams() [this.name],
valueOf: function () this.id,
@@ -411,14 +411,14 @@ var Modes = Module("modes", {
}),
StackElement: (function () {
const StackElement = Struct("main", "extended", "params", "saved");
StackElement.className = "Modes.StackElement";
StackElement.defaultValue("params", function () this.main.params);
update(StackElement.prototype, {
toString: function () !loaded.modes ? this.main : "[mode " +
this.main.name +
(!this.extended ? "" :
"(" + modes.all.filter(function (m) this.extended & m)
.join("|") +
")") + "]"
get toStringParams() !loaded.modes ? this.main.name : [
this.main.name,
<>({ modes.all.filter(function (m) this.extended & m, this).map(function (m) m.name).join("|") })</>
]
});
return StackElement;
})(),

View File

@@ -769,7 +769,8 @@ Class.prototype = {
toString: function () {
if (this.toStringParams)
var params = "(" + this.toStringParams.map(function (m) isArray(m) ? "[" + m + "]" :
isString(m) ? m.quote() : String(m)) + ")";
isString(m) ? m.quote() : String(m))
.join(", ") + ")";
return "[instance " + this.constructor.className + (params || "") + "]";
},