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:
RickyRister 2025-03-02 15:57:30 -08:00 committed by GitHub
parent 87c5d07807
commit e1964f21de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 33 additions and 8 deletions

View file

@ -289,6 +289,10 @@ void DeckEditorDeckDockWidget::setBannerCard(int /* changedIndex */)
emit deckChanged();
}
/**
* Sets the currently active deck for this tab
* @param _deck The deck. Takes ownership of the object
*/
void DeckEditorDeckDockWidget::setDeck(DeckLoader *_deck)
{
deckModel->setDeckList(_deck);

View file

@ -143,10 +143,10 @@ void DeckPreviewDeckTagsDisplayWidget::openTagEditDlg()
auto *deckEditor = qobject_cast<TabDeckEditor *>(currentParent);
QStringList knownTags;
QStringList allFiles = getAllFiles(SettingsCache::instance().getDeckPath());
auto *loader = new DeckLoader();
DeckLoader loader;
for (const QString &file : allFiles) {
loader->loadFromFile(file, DeckLoader::getFormatFromName(file), false);
QStringList tags = loader->getTags();
loader.loadFromFile(file, DeckLoader::getFormatFromName(file), false);
QStringList tags = loader.getTags();
knownTags.append(tags);
knownTags.removeDuplicates();
}