diff options
-rw-r--r-- | dive.c | 6 | ||||
-rw-r--r-- | gaspressures.c | 5 | ||||
-rw-r--r-- | qt-ui/profile/diveprofileitem.cpp | 2 |
3 files changed, 11 insertions, 2 deletions
@@ -722,6 +722,8 @@ void per_cylinder_mean_depth(struct dive *dive, struct divecomputer *dc, int *me if (dc->dctype == CCR) { // Do the same for the O2 cylinder int o2_cyl = get_cylinder_idx_by_use(dive, OXYGEN); + if (o2_cyl < 0) + return; mean[o2_cyl] = dc->meandepth.mm; duration[o2_cyl] = dc->duration.seconds; } @@ -775,6 +777,8 @@ static void fixup_pressure(struct dive *dive, struct sample *sample, enum cylind pressure = sample->o2cylinderpressure.mbar; index = get_cylinder_idx_by_use(dive, OXYGEN); } + if (index < 0) + return; if (!pressure) return; @@ -846,7 +850,7 @@ int explicit_first_cylinder(struct dive *dive, struct divecomputer *dc) if (ev && dc && dc->sample && ev->time.seconds == dc->sample[0].time.seconds) return get_cylinder_index(dive, ev); else if (dc->dctype == CCR) - return get_cylinder_idx_by_use(dive, DILUENT); + return MAX(get_cylinder_idx_by_use(dive, DILUENT), 0); else return 0; } diff --git a/gaspressures.c b/gaspressures.c index 58e570423..4edcf7e35 100644 --- a/gaspressures.c +++ b/gaspressures.c @@ -271,6 +271,8 @@ static void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi, if (o2_flag) { // Find the cylinder index (cyl) and pressure cyl = dive->oxygen_cylinder_index; + if (cyl < 0) + return; // Can we do this?!? pressure = O2CYLINDER_PRESSURE(entry); save_pressure = &(entry->o2cylinderpressure[SENSOR_PR]); save_interpolated = &(entry->o2cylinderpressure[INTERPOLATED_PR]); @@ -374,6 +376,8 @@ void populate_pressure_information(struct dive *dive, struct divecomputer *dc, s if (o2_flag) { // if this is a diluent cylinder: pressure = O2CYLINDER_PRESSURE(entry); cylinderid = dive->oxygen_cylinder_index; + if (cylinderid < 0) + goto GIVE_UP; } else { pressure = SENSOR_PRESSURE(entry); cylinderid = entry->cylinderindex; @@ -424,6 +428,7 @@ void populate_pressure_information(struct dive *dive, struct divecomputer *dc, s debug_print_pressures(pi); #endif +GIVE_UP: for (i = 0; i < MAX_CYLINDERS; i++) list_free(track_pr[i]); } diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index 038987fe7..8ee0f3494 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -618,7 +618,7 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo for (int i = 0, count = dataModel->rowCount(); i < count; i++) { entry = dataModel->data().entry + i; mbar = GET_PRESSURE(entry); - if (displayed_dive.dc.dctype == CCR) + if (displayed_dive.dc.dctype == CCR && displayed_dive.oxygen_cylinder_index >= 0) o2mbar = GET_O2CYLINDER_PRESSURE(entry); if (o2mbar) { |