[DeckList] Make DeckList not a QObject (#6383)

This commit is contained in:
RickyRister 2025-12-02 21:18:46 -08:00 committed by GitHub
parent d29e72ce72
commit 658ae83157
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 28 additions and 67 deletions

View file

@ -5,8 +5,11 @@
DeckListModel::DeckListModel(QObject *parent)
: QAbstractItemModel(parent), lastKnownColumn(1), lastKnownOrder(Qt::AscendingOrder)
{
// This class will leak the decklist object. We cannot safely delete it in the dtor because the deckList field is a
// non-owning pointer and another deckList might have been assigned to it.
// `DeckListModel::cleanList` also leaks for the same reason.
// TODO: fix the leak
deckList = new DeckList;
deckList->setParent(this);
root = new InnerDecklistNode;
}
@ -284,6 +287,7 @@ bool DeckListModel::setData(const QModelIndex &index, const QVariant &value, con
emitRecursiveUpdates(index);
deckList->refreshDeckHash();
emit deckHashChanged();
emit dataChanged(index, index);
return true;
@ -422,6 +426,7 @@ QModelIndex DeckListModel::addCard(const ExactCard &card, const QString &zoneNam
cardNode->setCardCollectorNumber(printingInfo.getProperty("num"));
cardNode->setCardProviderId(printingInfo.getProperty("uuid"));
deckList->refreshDeckHash();
emit deckHashChanged();
}
sort(lastKnownColumn, lastKnownOrder);
emitRecursiveUpdates(parentIndex);