mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Fix memory leaks from DeckLoader usage (#5665)
* add comment * stack allocate DeckLoader for loading tags * deckModel now takes ownership of DeckLoader * fix remaining * add comment
This commit is contained in:
parent
87c5d07807
commit
e1964f21de
7 changed files with 33 additions and 8 deletions
|
|
@ -18,6 +18,7 @@ DeckListModel::DeckListModel(QObject *parent)
|
|||
: QAbstractItemModel(parent), lastKnownColumn(1), lastKnownOrder(Qt::AscendingOrder)
|
||||
{
|
||||
deckList = new DeckLoader;
|
||||
deckList->setParent(this);
|
||||
connect(deckList, &DeckLoader::deckLoaded, this, &DeckListModel::rebuildTree);
|
||||
connect(deckList, &DeckLoader::deckHashChanged, this, &DeckListModel::deckHashChanged);
|
||||
root = new InnerDecklistNode;
|
||||
|
|
@ -26,7 +27,6 @@ DeckListModel::DeckListModel(QObject *parent)
|
|||
DeckListModel::~DeckListModel()
|
||||
{
|
||||
delete root;
|
||||
delete deckList;
|
||||
}
|
||||
|
||||
void DeckListModel::rebuildTree()
|
||||
|
|
@ -470,10 +470,14 @@ void DeckListModel::cleanList()
|
|||
setDeckList(new DeckLoader);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param _deck The deck. Takes ownership of the object
|
||||
*/
|
||||
void DeckListModel::setDeckList(DeckLoader *_deck)
|
||||
{
|
||||
delete deckList;
|
||||
deckList->deleteLater();
|
||||
deckList = _deck;
|
||||
deckList->setParent(this);
|
||||
connect(deckList, &DeckLoader::deckLoaded, this, &DeckListModel::rebuildTree);
|
||||
connect(deckList, &DeckLoader::deckHashChanged, this, &DeckListModel::deckHashChanged);
|
||||
rebuildTree();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue