From c092951052ef91c8773e32f94f2283546b2dbb84 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Sun, 20 Apr 2025 15:23:48 +0200 Subject: [PATCH] canvas: more safe check before drawing --- src/client/widgets/common/canvas.js | 5 ++++- src/client/widgets/sliders/fader.js | 2 +- src/client/widgets/sliders/range.js | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/client/widgets/common/canvas.js b/src/client/widgets/common/canvas.js index 869abc61..614283d8 100644 --- a/src/client/widgets/common/canvas.js +++ b/src/client/widgets/common/canvas.js @@ -101,7 +101,10 @@ class Canvas extends Widget { this.hasSize = true this.setVisibility() } - this.draw() + + if (this.width > 0 && this.height > 0 && this.visible) { + this.draw() + } }) diff --git a/src/client/widgets/sliders/fader.js b/src/client/widgets/sliders/fader.js index 1bb983dd..38d1aa34 100644 --- a/src/client/widgets/sliders/fader.js +++ b/src/client/widgets/sliders/fader.js @@ -390,7 +390,7 @@ class Fader extends Slider { this.shouldDrawPips = false } - if (this.pips) { + if (this.pips && this.pips.width && this.pips.height) { this.ctx.globalAlpha = 1 this.ctx.drawImage(this.pips, 0, 0) if (!compact) this.clearRect = [this.clearRect, [m + knobWidth / 2, 0, 12 * PXSCALE + this.pipsTextSize, height]] diff --git a/src/client/widgets/sliders/range.js b/src/client/widgets/sliders/range.js index 7c76d0a9..722a437c 100644 --- a/src/client/widgets/sliders/range.js +++ b/src/client/widgets/sliders/range.js @@ -389,7 +389,7 @@ class Range extends Fader { this.shouldDrawPips = false } - if (this.pips) { + if (this.pips && this.pips.width && this.pips.height) { this.ctx.globalAlpha = 1 this.ctx.drawImage(this.pips, 0, 0) if (!compact) this.clearRect = [this.clearRect, [m + knobWidth / 2, 0, 12 * PXSCALE + this.pipsTextSize, height]]