From bd93b4195f4e587c78506ac1d42dcfb705ff4945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Lecomte?= Date: Sun, 14 Sep 2025 11:29:03 +0200 Subject: [PATCH] fix(spectrogram): prevent errors for zero width Sometimes the screen width can be returned as zero, and this can in turn cause issues creating pixmaps. Make sure the width is always at least 1. --- friture/spectrogram_image.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/friture/spectrogram_image.py b/friture/spectrogram_image.py index 0beab46e..28271975 100644 --- a/friture/spectrogram_image.py +++ b/friture/spectrogram_image.py @@ -65,14 +65,16 @@ def resize(self, width, height): self.pixmap = self.pixmap.scaled(2 * width, height, QtCore.Qt.IgnoreAspectRatio, QtCore.Qt.SmoothTransformation) def setcanvas_height(self, canvas_height): - if self.canvas_height != int(canvas_height): - self.canvas_height = int(canvas_height) + canvas_height = max(1, int(canvas_height)) + if self.canvas_height != canvas_height: + self.canvas_height = canvas_height self.resize(self.canvas_width, self.canvas_height) self.logger.info("Spectrogram image: canvas_height changed, now: %d", int(canvas_height)) def setcanvas_width(self, canvas_width): - if self.canvas_width != int(canvas_width): - self.canvas_width = int(canvas_width) + canvas_width = max(1, int(canvas_width)) + if self.canvas_width != canvas_width: + self.canvas_width = canvas_width self.resize(self.canvas_width, self.canvas_height) self.canvasWidthChanged.emit(int(canvas_width)) self.logger.info("Spectrogram image: canvas_width changed, now: %d", int(canvas_width))