From 74638c5f65e62c82439ee59d0e35541de0590265 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 11 Mar 2015 11:17:05 -0700 Subject: [PATCH] Simplify the code that replaces a gas change event at t=0 Signed-off-by: Dirk Hohndel --- qt-ui/profile/profilewidget2.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 68b1cbe70..66ef84ac4 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -1393,21 +1393,16 @@ void ProfileWidget2::changeGas() if (seconds == 0) { bool eventRemoved = false; - QString tempStr = "gaschange"; - char *gaschangeStr = tempStr.toUtf8().data(); - - struct event *gasChangeEvent = get_next_event(current_dc->events, gaschangeStr); - struct event *temp; - - while (gasChangeEvent) { - temp = get_next_event(current_dc->events, gaschangeStr); + struct event *gasChangeEvent = current_dc->events; + while ((gasChangeEvent = get_next_event(gasChangeEvent, "gaschange")) != NULL) { if (gasChangeEvent->time.seconds == 0) { remove_event(gasChangeEvent); eventRemoved = true; + gasChangeEvent = current_dc->events; + } else { + gasChangeEvent = gasChangeEvent->next; } - gasChangeEvent = temp; } - if (eventRemoved) { mark_divelist_changed(true); replot();