Fix a recently introduce but in Raster#getCanvas().

This commit is contained in:
Jürg Lehni 2013-02-12 15:54:56 -08:00
parent 357b7dbc54
commit 9600fdb512
2 changed files with 8 additions and 4 deletions

View file

@ -1105,10 +1105,13 @@ var Item = this.Item = Base.extend(Callback, {
ctx = canvas.getContext('2d'), ctx = canvas.getContext('2d'),
matrix = new Matrix().scale(scale).translate(-bounds.x, -bounds.y); matrix = new Matrix().scale(scale).translate(-bounds.x, -bounds.y);
matrix.applyToContext(ctx); matrix.applyToContext(ctx);
// XXX: Decide how to handle _matrix // TODO: Decide how to handle _matrix
this.draw(ctx, {}); this.draw(ctx, {});
var raster = new Raster(canvas); var raster = new Raster(canvas);
raster.setBounds(bounds); raster.setBounds(bounds);
CanvasProvider.release(canvas);
// NOTE: We don't need to release the canvas since it now belongs to the
// Raster!
return raster; return raster;
}, },

View file

@ -163,11 +163,12 @@ var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{
// policies, wrap the call in try-catch and only set _canvas if we // policies, wrap the call in try-catch and only set _canvas if we
// succeeded. // succeeded.
try { try {
if (this._image)
this.getContext(true).drawImage(this._image, 0, 0);
this._canvas = canvas; this._canvas = canvas;
if (this._image)
this.getContext().drawImage(this._image, 0, 0);
} catch (e) { } catch (e) {
CanvasProvider.returnCanvas(canvas); this._canvas = null;
CanvasProvider.release(canvas);
} }
} }
return this._canvas; return this._canvas;