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);