Fix segfault when multiple cards are dragged from view zone (#5934)

This commit is contained in:
RickyRister 2025-05-10 16:44:32 -07:00 committed by GitHub
parent 9cf979d154
commit b423edf2b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 1 additions and 7 deletions

View file

@ -19,6 +19,7 @@ AbstractCardDragItem::AbstractCardDragItem(AbstractCardItem *_item,
if (parentDrag) { if (parentDrag) {
parentDrag->addChildDrag(this); parentDrag->addChildDrag(this);
setZValue(2000000007 + hotSpot.x() * 1000000 + hotSpot.y() * 1000 + 1000); setZValue(2000000007 + hotSpot.x() * 1000000 + hotSpot.y() * 1000 + 1000);
connect(parentDrag, &QObject::destroyed, this, &AbstractCardDragItem::deleteLater);
} else { } else {
hotSpot = QPointF{qBound(0.0, hotSpot.x(), static_cast<qreal>(CARD_WIDTH - 1)), hotSpot = QPointF{qBound(0.0, hotSpot.x(), static_cast<qreal>(CARD_WIDTH - 1)),
qBound(0.0, hotSpot.y(), static_cast<qreal>(CARD_HEIGHT - 1))}; qBound(0.0, hotSpot.y(), static_cast<qreal>(CARD_HEIGHT - 1))};
@ -43,12 +44,6 @@ AbstractCardDragItem::AbstractCardDragItem(AbstractCardItem *_item,
connect(item, &QObject::destroyed, this, &AbstractCardDragItem::deleteLater); connect(item, &QObject::destroyed, this, &AbstractCardDragItem::deleteLater);
} }
AbstractCardDragItem::~AbstractCardDragItem()
{
for (int i = 0; i < childDrags.size(); i++)
delete childDrags[i];
}
QPainterPath AbstractCardDragItem::shape() const QPainterPath AbstractCardDragItem::shape() const
{ {
QPainterPath shape; QPainterPath shape;

View file

@ -26,7 +26,6 @@ public:
return Type; return Type;
} }
AbstractCardDragItem(AbstractCardItem *_item, const QPointF &_hotSpot, AbstractCardDragItem *parentDrag = 0); AbstractCardDragItem(AbstractCardItem *_item, const QPointF &_hotSpot, AbstractCardDragItem *parentDrag = 0);
~AbstractCardDragItem() override;
QRectF boundingRect() const override QRectF boundingRect() const override
{ {
return QRectF(0, 0, CARD_WIDTH, CARD_HEIGHT); return QRectF(0, 0, CARD_WIDTH, CARD_HEIGHT);