mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-09 19:43:26 -08:00
Fix orphaned arrows when the draw shortcut repeats (#6789)
Holding or spamming the draw-arrow shortcut fires the action again before the previous local arrow has been placed. Every new arrow takes the mouse grab from the previous one, so the previous arrow never receives the release that deletes it. If the cursor had passed over a card meanwhile, the orphan stayed visible on the board. Track the in-progress arrow on the CardItem that started it and cancel it, together with any child arrows, before starting a new one. The attach-arrow shortcut (Ctrl+Alt+A) uses the same path, so it no longer leaks arrows either. Fixes #4329. Co-authored-by: mb <mbaecker@unforce.de>
This commit is contained in:
parent
01572bfce2
commit
80986266b9
4 changed files with 78 additions and 23 deletions
|
|
@ -70,6 +70,8 @@ public:
|
|||
|
||||
void onTargetDestroyed();
|
||||
void delArrow();
|
||||
/// Abandons an in-progress drag arrow, discarding any child arrows with it.
|
||||
virtual void cancel();
|
||||
void updatePath();
|
||||
void updatePath(const QPointF &endPoint);
|
||||
void startDrawAnimation();
|
||||
|
|
@ -112,12 +114,13 @@ class ArrowDragItem : public ArrowItem
|
|||
private:
|
||||
PlayerLogic *player;
|
||||
int deleteInPhase;
|
||||
QList<ArrowDragItem *> childArrows;
|
||||
QList<QPointer<ArrowDragItem>> childArrows;
|
||||
QMetaObject::Connection positionConnection;
|
||||
|
||||
public:
|
||||
ArrowDragItem(PlayerLogic *_owner, ArrowTarget *_startItem, const QColor &_color, int _deleteInPhase);
|
||||
void addChildArrow(ArrowDragItem *child);
|
||||
void cancel() override;
|
||||
|
||||
protected:
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
|
|
@ -129,12 +132,13 @@ class ArrowAttachItem : public ArrowItem
|
|||
Q_OBJECT
|
||||
private:
|
||||
PlayerLogic *player;
|
||||
QList<ArrowAttachItem *> childArrows;
|
||||
QList<QPointer<ArrowAttachItem>> childArrows;
|
||||
QMetaObject::Connection positionConnection;
|
||||
|
||||
public:
|
||||
explicit ArrowAttachItem(ArrowTarget *_startItem);
|
||||
void addChildArrow(ArrowAttachItem *child);
|
||||
void cancel() override;
|
||||
|
||||
protected:
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue