Merge pull request #9320 from JosJuice/remove-patch-crash

DolphinQt: Fix crash after removing extra patch line
This commit is contained in:
Léo Lam 2020-12-15 00:01:07 +01:00 committed by GitHub
commit 2c2ec16b53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -164,15 +164,22 @@ QGroupBox* NewPatchDialog::CreateEntry(PatchEngine::PatchEntry& entry)
value->setPalette(palette); value->setPalette(palette);
}); });
connect(remove, &QPushButton::clicked, [this, box, entry] { connect(remove, &QPushButton::clicked, [this, box, offset, value, entry] {
if (m_patch.entries.size() > 1) if (m_patch.entries.size() > 1)
{ {
box->setVisible(false); box->setVisible(false);
m_entry_layout->removeWidget(box); m_entry_layout->removeWidget(box);
box->deleteLater(); box->deleteLater();
m_patch.entries.erase( m_patch.entries.erase(
std::find_if(m_patch.entries.begin(), m_patch.entries.end(), std::find_if(m_patch.entries.begin(), m_patch.entries.end(),
[entry](const PatchEngine::PatchEntry& e) { return PatchEq(e, entry); })); [entry](const PatchEngine::PatchEntry& e) { return PatchEq(e, entry); }));
const auto it =
std::remove_if(m_edits.begin(), m_edits.end(), [offset, value](QLineEdit* line_edit) {
return line_edit == offset || line_edit == value;
});
m_edits.erase(it, m_edits.end());
} }
}); });