Set DeckList parent when ownership changes (#6317)

* Initialize all deck list member variables in constructor.

Took 10 minutes

* Revert "Initialize all deck list member variables in constructor."

This reverts commit fba2455808.

* setParent

Took 1 hour 2 minutes

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2025-11-15 10:28:54 +01:00 committed by GitHub
parent 84e0732fb1
commit 0f60824749
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 0 deletions

View file

@ -33,6 +33,7 @@ DeckLoader::DeckLoader(QObject *parent)
DeckLoader::DeckLoader(QObject *parent, DeckList *_deckList) DeckLoader::DeckLoader(QObject *parent, DeckList *_deckList)
: QObject(parent), deckList(_deckList), lastFileFormat(CockatriceFormat), lastRemoteDeckId(-1) : QObject(parent), deckList(_deckList), lastFileFormat(CockatriceFormat), lastRemoteDeckId(-1)
{ {
deckList->setParent(this);
} }
DeckLoader::DeckLoader(const DeckLoader &other) DeckLoader::DeckLoader(const DeckLoader &other)
@ -44,6 +45,7 @@ DeckLoader::DeckLoader(const DeckLoader &other)
void DeckLoader::setDeckList(DeckList *_deckList) void DeckLoader::setDeckList(DeckList *_deckList)
{ {
deckList = _deckList; deckList = _deckList;
deckList->setParent(this);
} }
bool DeckLoader::loadFromFile(const QString &fileName, FileFormat fmt, bool userRequest) bool DeckLoader::loadFromFile(const QString &fileName, FileFormat fmt, bool userRequest)

View file

@ -375,6 +375,7 @@ void DeckEditorDeckDockWidget::syncBannerCardComboBoxSelectionWithDeck()
void DeckEditorDeckDockWidget::setDeck(DeckLoader *_deck) void DeckEditorDeckDockWidget::setDeck(DeckLoader *_deck)
{ {
deckLoader = _deck; deckLoader = _deck;
deckLoader->setParent(this);
deckModel->setDeckList(deckLoader->getDeckList()); deckModel->setDeckList(deckLoader->getDeckList());
connect(deckLoader, &DeckLoader::deckLoaded, deckModel, &DeckListModel::rebuildTree); connect(deckLoader, &DeckLoader::deckLoaded, deckModel, &DeckListModel::rebuildTree);
connect(deckLoader->getDeckList(), &DeckList::deckHashChanged, deckModel, &DeckListModel::deckHashChanged); connect(deckLoader->getDeckList(), &DeckList::deckHashChanged, deckModel, &DeckListModel::deckHashChanged);