diff --git a/cockatrice/src/decklistmodel.cpp b/cockatrice/src/decklistmodel.cpp index 8a3b8b0f..039db364 100644 --- a/cockatrice/src/decklistmodel.cpp +++ b/cockatrice/src/decklistmodel.cpp @@ -307,11 +307,12 @@ void DeckListModel::sortHelper(InnerDecklistNode *node, Qt::SortOrder order) QVector > sortResult = node->sort(order); QModelIndexList from, to; + int columns = columnCount(); for (int i = sortResult.size() - 1; i >= 0; --i) { const int fromRow = sortResult[i].first; const int toRow = sortResult[i].second; AbstractDecklistNode *temp = node->at(toRow); - for (int j = 0; j < columnCount(); ++j) { + for (int j = 0; j < columns; ++j) { from << createIndex(fromRow, j, temp); to << createIndex(toRow, j, temp); }