grid: remove unused imports, stop animation before widget deletion

Unused: Path, Post, QPainterPath, QMenu, QApplication.

FlowLayout.clear() now stops any in-flight fade animation before
calling deleteLater() on thumbnails. Without this, a mid-flight
QPropertyAnimation can fire property updates on a widget that's
queued for deletion.
This commit is contained in:
pax 2026-04-11 19:28:13 -05:00
parent a51c9a1fda
commit e262a2d3bb

View File

@ -3,22 +3,17 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from pathlib import Path
log = logging.getLogger("booru") log = logging.getLogger("booru")
from PySide6.QtCore import Qt, Signal, QSize, QRect, QRectF, QMimeData, QUrl, QPoint, Property, QPropertyAnimation, QEasingCurve from PySide6.QtCore import Qt, Signal, QSize, QRect, QRectF, QMimeData, QUrl, QPoint, Property, QPropertyAnimation, QEasingCurve
from PySide6.QtGui import QPixmap, QPainter, QPainterPath, QColor, QPen, QKeyEvent, QWheelEvent, QDrag, QMouseEvent from PySide6.QtGui import QPixmap, QPainter, QColor, QPen, QKeyEvent, QWheelEvent, QDrag, QMouseEvent
from PySide6.QtWidgets import ( from PySide6.QtWidgets import (
QWidget, QWidget,
QScrollArea, QScrollArea,
QMenu,
QApplication,
QRubberBand, QRubberBand,
) )
from ..core.api.base import Post
THUMB_SIZE = 180 THUMB_SIZE = 180
THUMB_SPACING = 2 THUMB_SPACING = 2
BORDER_WIDTH = 2 BORDER_WIDTH = 2
@ -382,6 +377,8 @@ class FlowLayout(QWidget):
def clear(self) -> None: def clear(self) -> None:
for w in self._items: for w in self._items:
if hasattr(w, '_fade_anim') and w._fade_anim is not None:
w._fade_anim.stop()
w.setParent(None) # type: ignore w.setParent(None) # type: ignore
w.deleteLater() w.deleteLater()
self._items.clear() self._items.clear()