Correctly handle Raster#setImage(null)

This commit is contained in:
Jürg Lehni 2014-04-13 18:11:34 +02:00
parent ea81df6572
commit ee729622e0

View file

@ -193,7 +193,7 @@ var Raster = Item.extend(/** @lends Raster# */{
if (this._canvas) if (this._canvas)
CanvasProvider.release(this._canvas); CanvasProvider.release(this._canvas);
// Due to similarities, we can handle both canvas and image types here. // Due to similarities, we can handle both canvas and image types here.
if (image.getContext) { if (image && image.getContext) {
// A canvas object // A canvas object
this._image = null; this._image = null;
this._canvas = image; this._canvas = image;
@ -207,8 +207,8 @@ var Raster = Item.extend(/** @lends Raster# */{
// apparently can have width / height set to 0 when the image is // apparently can have width / height set to 0 when the image is
// invisible in the document. // invisible in the document.
this._size = new Size( this._size = new Size(
image.naturalWidth || image.width, image ? image.naturalWidth || image.width : 0,
image.naturalHeight || image.height); image ? image.naturalHeight || image.height : 0);
this._context = null; this._context = null;
this._changed(/*#=*/ Change.GEOMETRY | /*#=*/ Change.PIXELS); this._changed(/*#=*/ Change.GEOMETRY | /*#=*/ Change.PIXELS);
}, },