Merge pull request #171 from huderlem/fix-event-deletion-crash
Fix event deletion crash
This commit is contained in:
commit
81d02f57a5
2 changed files with 9 additions and 1 deletions
|
@ -10,6 +10,10 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
|
|||
### Added
|
||||
- Add optional support for Poryscript script files via the `use_poryscript` config option.
|
||||
|
||||
### Fixed
|
||||
- Fix index-out-of-bounds crash when deleting the last event in an event type group.
|
||||
|
||||
|
||||
## [2.0.0] - 2019-10-16
|
||||
### Breaking Changes
|
||||
- Accomodate event object graphics pointer table being explicitly indexed. From changes introduced in commits [cdae0c1444bed98e652c87dc3e3edcecacfef8be](https://github.com/pret/pokeemerald/commit/cdae0c1444bed98e652c87dc3e3edcecacfef8be) and [0e8ccfc4fd3544001f4c25fafd401f7558bdefba](https://github.com/pret/pokeruby/commit/0e8ccfc4fd3544001f4c25fafd401f7558bdefba).
|
||||
|
|
|
@ -1785,11 +1785,15 @@ void MainWindow::on_toolButton_deleteObject_clicked()
|
|||
for (DraggablePixmapItem *item : *editor->selected_events) {
|
||||
QString event_group = item->event->get("event_group_type");
|
||||
int index = editor->map->events.value(event_group).indexOf(item->event);
|
||||
// Get the index for the event that should be selected after this event has been deleted.
|
||||
// If it's at the end of the list, select the previous event, otherwise select the next one.
|
||||
if (index != editor->map->events.value(event_group).size() - 1)
|
||||
index++;
|
||||
else
|
||||
index--;
|
||||
Event *event = editor->map->events.value(event_group).at(index);
|
||||
Event *event = nullptr;
|
||||
if (index >= 0)
|
||||
event = editor->map->events.value(event_group).at(index);
|
||||
if (event_group != "heal_event_group") {
|
||||
for (QGraphicsItem *child : editor->events_group->childItems()) {
|
||||
DraggablePixmapItem *event_item = static_cast<DraggablePixmapItem *>(child);
|
||||
|
|
Loading…
Reference in a new issue