From 968be8a06f6d2eb50f140992f7214428f16d2f9b Mon Sep 17 00:00:00 2001 From: RickyRister <42636155+RickyRister@users.noreply.github.com> Date: Wed, 31 Dec 2025 03:00:23 -0800 Subject: [PATCH] Fix bug with next/prev buttons in PrintingSelector (#6453) * Hacky fix and debug messages * remove debug * add todo --- .../widgets/deck_editor/deck_editor_deck_dock_widget.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cockatrice/src/interface/widgets/deck_editor/deck_editor_deck_dock_widget.cpp b/cockatrice/src/interface/widgets/deck_editor/deck_editor_deck_dock_widget.cpp index 3ca171a15..b8ebc1419 100644 --- a/cockatrice/src/interface/widgets/deck_editor/deck_editor_deck_dock_widget.cpp +++ b/cockatrice/src/interface/widgets/deck_editor/deck_editor_deck_dock_widget.cpp @@ -571,6 +571,15 @@ void DeckEditorDeckDockWidget::changeSelectedCard(int changeBy) // Get the current index of the selected item auto deckViewCurrentIndex = deckView->currentIndex(); + // For some reason, if the deckModel is modified but the view is not manually reselected, + // currentIndex will return an index for the underlying deckModel instead of the proxy. + // That index will return an invalid index when indexBelow/indexAbove crosses a header node, + // causing the selection to fail to move down. + /// \todo Figure out why it's happening so we can do a proper fix instead of a hacky workaround + if (deckViewCurrentIndex.model() == proxy->sourceModel()) { + deckViewCurrentIndex = proxy->mapFromSource(deckViewCurrentIndex); + } + auto nextIndex = deckViewCurrentIndex.siblingAtRow(deckViewCurrentIndex.row() + changeBy); if (!nextIndex.isValid()) { nextIndex = deckViewCurrentIndex;