From 2f3113f0f6925efe1fb945fe34e70746d08e22ed Mon Sep 17 00:00:00 2001 From: Gabriel Selzer Date: Thu, 12 Dec 2024 18:27:54 -0600 Subject: [PATCH] End painter when drawing colormap (#262) * End painter when drawing colormap * Only end painter if we created it --- src/superqt/cmap/_cmap_utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/superqt/cmap/_cmap_utils.py b/src/superqt/cmap/_cmap_utils.py index 840f0df8..219b4a92 100644 --- a/src/superqt/cmap/_cmap_utils.py +++ b/src/superqt/cmap/_cmap_utils.py @@ -121,6 +121,10 @@ def paintEvent(self, event) -> None: painter.setBrush(gradient) painter.drawRect(rect) + # If we created a new Painter, free its resources + if isinstance(painter_or_device, QPaintDevice): + painter.end() + def _draw_checkerboard( painter: QPainter, rect: QRect | QRectF, checker_size: int