Add defensive checks on index and iterators
This commit is contained in:
parent
f50743b3d0
commit
8567d161b5
2 changed files with 16 additions and 2 deletions
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"files.associations": {
|
||||
"map": "cpp"
|
||||
}
|
||||
}
|
|
@ -374,13 +374,22 @@ void Editor::deleteWildMonGroup() {
|
|||
|
||||
if (msgBox.clickedButton() == deleteButton) {
|
||||
auto it = project->wildMonData.find(map->constantName);
|
||||
it.value().erase(labelCombo->currentText());
|
||||
if (it == project->wildMonData.end()) {
|
||||
logError(QString("Failed to find data for map %s. Unable to delete").arg(map->constantName));
|
||||
return;
|
||||
}
|
||||
|
||||
int i = project->encounterGroupLabels.indexOf(labelCombo->currentText());
|
||||
if (i < 0) {
|
||||
logError(QString("Failed to find selected wild mon group: %s. Unable to delete")
|
||||
.arg(labelCombo->currentText()));
|
||||
return;
|
||||
}
|
||||
|
||||
it.value().erase(labelCombo->currentText());
|
||||
project->encounterGroupLabels.remove(i);
|
||||
|
||||
displayWildMonTables();
|
||||
|
||||
emit wildMonDataChanged();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue