From 738ece9cd5f0fe0870fcdc05177443390a51a546 Mon Sep 17 00:00:00 2001 From: pax Date: Sat, 11 Apr 2026 22:40:49 -0500 Subject: [PATCH] grid: replace _source_pixmap with _source_path Store the on-disk thumbnail path instead of a second decoded QPixmap per ThumbnailWidget. Saves ~90 KB per widget in decoded pixel memory. The source pixmap was only needed for the settings thumbnail-resize path, which now re-decodes from disk (rare operation). behavior change: thumbnail resize in settings re-reads from disk instead of scaling from a held pixmap. No visual difference. --- booru_viewer/gui/grid.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/booru_viewer/gui/grid.py b/booru_viewer/gui/grid.py index e943862..f91327c 100644 --- a/booru_viewer/gui/grid.py +++ b/booru_viewer/gui/grid.py @@ -74,7 +74,7 @@ class ThumbnailWidget(QWidget): super().__init__(parent) self.index = index self._pixmap: QPixmap | None = None - self._source_pixmap: QPixmap | None = None # original, for re-scaling on size change + self._source_path: str | None = None # on-disk path, for re-scaling on size change self._selected = False self._multi_selected = False self._bookmarked = False @@ -97,8 +97,9 @@ class ThumbnailWidget(QWidget): self.setFixedSize(THUMB_SIZE, THUMB_SIZE) self.setMouseTracking(True) - def set_pixmap(self, pixmap: QPixmap) -> None: - self._source_pixmap = pixmap + def set_pixmap(self, pixmap: QPixmap, path: str | None = None) -> None: + if path is not None: + self._source_path = path self._pixmap = pixmap.scaled( THUMB_SIZE - 4, THUMB_SIZE - 4, Qt.AspectRatioMode.KeepAspectRatio,