mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 08:34:52 -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
|
|
@ -63,13 +63,14 @@ void DlgLoadDeckFromClipboard::actOK()
|
|||
QTextStream stream(&buffer);
|
||||
|
||||
auto *deckLoader = new DeckLoader;
|
||||
deckLoader->setParent(this);
|
||||
|
||||
if (buffer.contains("<cockatrice_deck version=\"1\">")) {
|
||||
if (deckLoader->loadFromString_Native(buffer)) {
|
||||
deckList = deckLoader;
|
||||
accept();
|
||||
} else {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Invalid deck list."));
|
||||
delete deckLoader;
|
||||
}
|
||||
} else if (deckLoader->loadFromStream_Plain(stream)) {
|
||||
deckList = deckLoader;
|
||||
|
|
@ -81,7 +82,6 @@ void DlgLoadDeckFromClipboard::actOK()
|
|||
accept();
|
||||
} else {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Invalid deck list."));
|
||||
delete deckLoader;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue