Fix exceptions in ProxyContext when drawing bitmaps.

This commit is contained in:
Jürg Lehni 2014-05-13 12:33:39 +02:00
parent e1ed7f3294
commit f56efd6471

View file

@ -59,6 +59,15 @@ var ProxyContext = new function() {
return str;
}
};
function stringify(value) {
try {
return JSON.stringify(value);
} catch (e) {
return value + '';
}
}
Base.each(descriptions, function(description) {
var match = description.match(/^([^(]+)(\()*/),
name = match[1],
@ -69,7 +78,7 @@ var ProxyContext = new function() {
this._indents--;
console.log(this.getIndentation() + 'ctx.' + name + '('
+ Array.prototype.slice.call(arguments, 0)
.map(JSON.stringify).join(', ')
.map(stringify).join(', ')
+ ');');
if (name === 'save')
this._indents++;
@ -83,7 +92,7 @@ var ProxyContext = new function() {
set: function(value) {
console.log(this.getIndentation() + 'ctx.' + name + ' = '
+ JSON.stringify(value) + ';');
+ stringify(value) + ';');
return this._ctx[name] = value;
}
};