aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-03-11 11:24:30 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-03-11 11:44:25 -0700
commit0739da38c59e966855c28a26ea252316149f796b (patch)
tree3e465d372722e934375390483f517941c07c1942 /qt-ui
parente121b4b548598ea16976980c0fc4af4dcd948b07 (diff)
downloadsubsurface-0739da38c59e966855c28a26ea252316149f796b.tar.gz
Don't allow two gas changes at the same time
t = 0 isn't really special here. We shouldn't allow two gas changes at the same time, period. We also can do away with the special handling to mark the dive list changed and replot things if a gas change gets removed. That's done at the end of this function either way. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/profile/profilewidget2.cpp24
1 files changed, 8 insertions, 16 deletions
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 36b9c6468..398934c68 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -1394,24 +1394,16 @@ void ProfileWidget2::changeGas()
// no gas changes before the dive starts
seconds = seconds > 0 ?: 0;
- if (seconds == 0) {
- bool eventRemoved = false;
- 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;
- }
- }
- if (eventRemoved) {
- mark_divelist_changed(true);
- replot();
+ // if there is a gas change at this time stamp, remove it before adding the new one
+ struct event *gasChangeEvent = current_dc->events;
+ while ((gasChangeEvent = get_next_event(gasChangeEvent, "gaschange")) != NULL) {
+ if (gasChangeEvent->time.seconds == seconds) {
+ remove_event(gasChangeEvent);
+ gasChangeEvent = current_dc->events;
+ } else {
+ gasChangeEvent = gasChangeEvent->next;
}
}
-
validate_gas(gas.toUtf8().constData(), &gasmix);
QRegExp rx("\\(\\D*(\\d+)");
int tank;