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