mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-27 20:58:47 +00:00
undo: fix RemoveEvent if we can't find the event
We check for the event, but then access it anyway even if it doesn't exist. Should not happen, but let's be safe. Found by Coverity. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
5c6ca2c1ce
commit
e305546046
1 changed files with 6 additions and 4 deletions
|
@ -115,19 +115,21 @@ void RenameEvent::undoit()
|
|||
redoit();
|
||||
}
|
||||
|
||||
RemoveEvent::RemoveEvent(struct dive *d, int dcNr, int idx) : EventBase(d, dcNr),
|
||||
idx(idx), cylinder(-1)
|
||||
RemoveEvent::RemoveEvent(struct dive *d, int dcNr, int idxIn) : EventBase(d, dcNr),
|
||||
idx(idxIn), cylinder(-1)
|
||||
{
|
||||
struct divecomputer *dc = d->get_dc(dcNr);
|
||||
event *ev = get_event(dc, idx);
|
||||
if (ev && (ev->type == SAMPLE_EVENT_GASCHANGE2 || ev->type == SAMPLE_EVENT_GASCHANGE))
|
||||
if (!ev)
|
||||
idx = -1;
|
||||
if (ev->type == SAMPLE_EVENT_GASCHANGE2 || ev->type == SAMPLE_EVENT_GASCHANGE)
|
||||
cylinder = ev->gas.index;
|
||||
setText(Command::Base::tr("Remove %1 event").arg(ev->name.c_str()));
|
||||
}
|
||||
|
||||
bool RemoveEvent::workToBeDone()
|
||||
{
|
||||
return true;
|
||||
return idx >= 0;
|
||||
}
|
||||
|
||||
void RemoveEvent::redoit()
|
||||
|
|
Loading…
Reference in a new issue