mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Correct usage of current_dive to displayed_dive
current_dive is the selected dive, and displayed_dive is the one we are currently drawing. They are quite often the same one, but not in the case of adding a dive for example. This fixes potential null pointer dereferences in the case of a blank divelist, and makes sure we use the correct data in the case of adding and planning dives. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
606bf377c5
commit
8e5eb71e0b
1 changed files with 2 additions and 2 deletions
|
@ -95,7 +95,7 @@ void DiveEventItem::setupToolTipString()
|
|||
// We need to look at row + 1, where the new gas is active to find what we are switching to.
|
||||
int cylinder_idx = dataModel->data(dataModel->index(result.first().row() + 1, DivePlotDataModel::CYLINDERINDEX)).toInt();
|
||||
name += ": ";
|
||||
name += gasname(¤t_dive->cylinder[cylinder_idx].gasmix);
|
||||
name += gasname(&displayed_dive.cylinder[cylinder_idx].gasmix);
|
||||
} else if (type == SAMPLE_EVENT_PO2 && name == "SP change") {
|
||||
name += QString(":%1").arg((double)value / 1000);
|
||||
} else {
|
||||
|
@ -128,7 +128,7 @@ bool DiveEventItem::shouldBeHidden()
|
|||
* Don't bother showing them if they match the first gas already
|
||||
*/
|
||||
if (!strcmp(event->name, "gaschange") && event->time.seconds <= 30) {
|
||||
struct dive *dive = current_dive;
|
||||
struct dive *dive = &displayed_dive;
|
||||
if (dive && get_cylinder_index(dive, event) == 0)
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue