mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
core: fix deletion of events in fixup_dc_events()
If there were more than one redundant event in the 60 sec range, the event would be deleted multiple time, leading to a crash. Only mark for deletion once. Moreover, don't consider events that were already marked for deletion, because that would mean that redundant events all 59 secs would lead to all events (but the first one) deleted. Finally, optimize the loop by stopping once the 60 sec limit is reached. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
0dc47882cb
commit
26c594382e
1 changed files with 7 additions and 2 deletions
|
@ -757,9 +757,14 @@ static void fixup_dc_events(struct divecomputer &dc)
|
|||
continue;
|
||||
for (int idx2 = idx - 1; idx2 > 0; --idx2) {
|
||||
const auto &prev = dc.events[idx2];
|
||||
if (prev.name == event.name && prev.flags == event.flags &&
|
||||
event.time.seconds - prev.time.seconds < 61)
|
||||
if (event.time.seconds - prev.time.seconds > 60)
|
||||
break;
|
||||
if (range_contains(to_delete, idx2))
|
||||
continue;
|
||||
if (prev.name == event.name && prev.flags == event.flags) {
|
||||
to_delete.push_back(idx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Delete from back to not invalidate indexes
|
||||
|
|
Loading…
Reference in a new issue