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:
unf0rce 2026-11-07 16:53:53 +01:00 • committed by GitHub
parent 01572bfce2
commit 80986266b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 78 additions and 23 deletions

View file

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