From 9600fdb512ddb58669e50b3c5852d492f64cf825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 12 Feb 2013 15:54:56 -0800 Subject: [PATCH] Fix a recently introduce but in Raster#getCanvas(). --- src/item/Item.js | 5 ++++- src/item/Raster.js | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/item/Item.js b/src/item/Item.js index ae8376da..832af936 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -1105,10 +1105,13 @@ var Item = this.Item = Base.extend(Callback, { ctx = canvas.getContext('2d'), matrix = new Matrix().scale(scale).translate(-bounds.x, -bounds.y); matrix.applyToContext(ctx); - // XXX: Decide how to handle _matrix + // TODO: Decide how to handle _matrix this.draw(ctx, {}); var raster = new Raster(canvas); raster.setBounds(bounds); + CanvasProvider.release(canvas); + // NOTE: We don't need to release the canvas since it now belongs to the + // Raster! return raster; }, diff --git a/src/item/Raster.js b/src/item/Raster.js index b44efa54..ab0606a6 100644 --- a/src/item/Raster.js +++ b/src/item/Raster.js @@ -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 // succeeded. try { - if (this._image) - this.getContext(true).drawImage(this._image, 0, 0); this._canvas = canvas; + if (this._image) + this.getContext().drawImage(this._image, 0, 0); } catch (e) { - CanvasProvider.returnCanvas(canvas); + this._canvas = null; + CanvasProvider.release(canvas); } } return this._canvas;