From 95f54f0576d01b214ad75e1b33d599c2fab4084f Mon Sep 17 00:00:00 2001 From: abakkk Date: Sun, 7 Jun 2020 21:53:08 +0200 Subject: [PATCH] fix undefined 'state' property ``` JS WARNING: [/home/.../draw.js 997]: reference to undefined property "state" ``` The state property is undefined if the element is loaded from json file. --- draw.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/draw.js b/draw.js index a3c7743..ae32b05 100644 --- a/draw.js +++ b/draw.js @@ -994,7 +994,8 @@ const DrawingElement = new Lang.Class({ } else if (shape == Shapes.TEXT && points.length == 2) { this.rotate(cr, trans.angle, trans.center[0], trans.center[1]); - if (this.state == TextState.DRAWING) + // the state property is undefined if the element is loaded from json file + if (this.state !== undefined && this.state == TextState.DRAWING) cr.rectangle(points[0][0], points[0][1], points[1][0] - points[0][0], points[1][1] - points[0][1]); cr.selectFontFace(this.font.family, this.font.style, this.font.weight); cr.setFontSize(Math.abs(points[1][1] - points[0][1]));