From b423edf2b56635cdd048dafc665d80d8ee4a0389 Mon Sep 17 00:00:00 2001 From: RickyRister <42636155+RickyRister@users.noreply.github.com> Date: Sat, 10 May 2025 16:44:32 -0700 Subject: [PATCH] Fix segfault when multiple cards are dragged from view zone (#5934) --- cockatrice/src/game/board/abstract_card_drag_item.cpp | 7 +------ cockatrice/src/game/board/abstract_card_drag_item.h | 1 - 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/cockatrice/src/game/board/abstract_card_drag_item.cpp b/cockatrice/src/game/board/abstract_card_drag_item.cpp index a7234c3d4..d7b0b7d46 100644 --- a/cockatrice/src/game/board/abstract_card_drag_item.cpp +++ b/cockatrice/src/game/board/abstract_card_drag_item.cpp @@ -19,6 +19,7 @@ AbstractCardDragItem::AbstractCardDragItem(AbstractCardItem *_item, if (parentDrag) { parentDrag->addChildDrag(this); setZValue(2000000007 + hotSpot.x() * 1000000 + hotSpot.y() * 1000 + 1000); + connect(parentDrag, &QObject::destroyed, this, &AbstractCardDragItem::deleteLater); } else { hotSpot = QPointF{qBound(0.0, hotSpot.x(), static_cast(CARD_WIDTH - 1)), qBound(0.0, hotSpot.y(), static_cast(CARD_HEIGHT - 1))}; @@ -43,12 +44,6 @@ AbstractCardDragItem::AbstractCardDragItem(AbstractCardItem *_item, 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 shape; diff --git a/cockatrice/src/game/board/abstract_card_drag_item.h b/cockatrice/src/game/board/abstract_card_drag_item.h index 85ce38b15..a411a24d1 100644 --- a/cockatrice/src/game/board/abstract_card_drag_item.h +++ b/cockatrice/src/game/board/abstract_card_drag_item.h @@ -26,7 +26,6 @@ public: return Type; } AbstractCardDragItem(AbstractCardItem *_item, const QPointF &_hotSpot, AbstractCardDragItem *parentDrag = 0); - ~AbstractCardDragItem() override; QRectF boundingRect() const override { return QRectF(0, 0, CARD_WIDTH, CARD_HEIGHT);