From 60cf4e0bebbae5a12642a272a4dd381398344ea8 Mon Sep 17 00:00:00 2001 From: pax Date: Sat, 11 Apr 2026 23:10:54 -0500 Subject: [PATCH] grid: fix fade animation cleanup crashing FlowLayout.clear The previous deleteLater on the QPropertyAnimation left a dangling self._fade_anim reference to a dead C++ object. When the next search called FlowLayout.clear(), calling .stop() on the dead animation threw RuntimeError and aborted widget cleanup, leaving stale thumbnails in the grid. Now the finished callback nulls self._fade_anim before scheduling deletion, so clear() never touches a dead object. --- booru_viewer/gui/grid.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/booru_viewer/gui/grid.py b/booru_viewer/gui/grid.py index a1e2706..6356b28 100644 --- a/booru_viewer/gui/grid.py +++ b/booru_viewer/gui/grid.py @@ -111,10 +111,16 @@ class ThumbnailWidget(QWidget): anim.setStartValue(0.0) anim.setEndValue(1.0) anim.setEasingCurve(QEasingCurve.Type.OutCubic) - anim.finished.connect(anim.deleteLater) + anim.finished.connect(lambda: self._on_fade_done(anim)) self._fade_anim = anim anim.start() + def _on_fade_done(self, anim: QPropertyAnimation) -> None: + """Clear the reference then schedule deletion.""" + if self._fade_anim is anim: + self._fade_anim = None + anim.deleteLater() + def set_selected(self, selected: bool) -> None: self._selected = selected self.update()