From 999733fc0fa92728d6ebd70bcab8ae3efa6266d1 Mon Sep 17 00:00:00 2001 From: RickyRister <42636155+RickyRister@users.noreply.github.com> Date: Fri, 23 Jan 2026 00:18:05 -0800 Subject: [PATCH] [VDE] Fix right click to remove card not working (#6549) * fix typo * fix crash --- .../widgets/deck_editor/deck_state_manager.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cockatrice/src/interface/widgets/deck_editor/deck_state_manager.cpp b/cockatrice/src/interface/widgets/deck_editor/deck_state_manager.cpp index 412954bb8..09254608e 100644 --- a/cockatrice/src/interface/widgets/deck_editor/deck_state_manager.cpp +++ b/cockatrice/src/interface/widgets/deck_editor/deck_state_manager.cpp @@ -201,17 +201,19 @@ QModelIndex DeckStateManager::decrementCard(const ExactCard &card, const QString return {}; } - bool success = offsetCountAtIndex(idx, false); + bool success = offsetCountAtIndex(idx, -1); if (!success) { return {}; } - if (idx.isValid()) { - emit focusIndexChanged(idx, true); + // old index is no longer safe since rows could have been removed + QModelIndex newIdx = deckListModel->findCard(card.getName(), zoneName, providerId, collectorNumber); + if (newIdx.isValid()) { + emit focusIndexChanged(newIdx, true); } - return idx; + return newIdx; } static bool doSwapCard(DeckListModel *model,