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.
This commit is contained in:
parent
692a0c1569
commit
60cf4e0beb
@ -111,10 +111,16 @@ class ThumbnailWidget(QWidget):
|
|||||||
anim.setStartValue(0.0)
|
anim.setStartValue(0.0)
|
||||||
anim.setEndValue(1.0)
|
anim.setEndValue(1.0)
|
||||||
anim.setEasingCurve(QEasingCurve.Type.OutCubic)
|
anim.setEasingCurve(QEasingCurve.Type.OutCubic)
|
||||||
anim.finished.connect(anim.deleteLater)
|
anim.finished.connect(lambda: self._on_fade_done(anim))
|
||||||
self._fade_anim = anim
|
self._fade_anim = anim
|
||||||
anim.start()
|
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:
|
def set_selected(self, selected: bool) -> None:
|
||||||
self._selected = selected
|
self._selected = selected
|
||||||
self.update()
|
self.update()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user