mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
Fix crash on right click dive trip
A null pointer dereference occured after right click on a dive trip because updateDiveInfo was called with dive == -1 causing get_dive(int) to return null. Wrap to avoid crash and clear dive info widget text labels. [Dirk Hohndel: this is different from the fix I had committed earlier; I decided to combine the ideas, clean this one up a bit more and this is the result] Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
661aa67e89
commit
b5d5b05140
1 changed files with 31 additions and 18 deletions
|
@ -87,26 +87,39 @@ void MainTab::updateDiveInfo(int dive)
|
|||
UPDATE_TEXT(d, suit);
|
||||
UPDATE_TEXT(d, divemaster);
|
||||
UPDATE_TEXT(d, buddy);
|
||||
if (d)
|
||||
if (d) {
|
||||
ui->rating->setCurrentStars(d->rating);
|
||||
else
|
||||
ui->rating->setCurrentStars(0);
|
||||
ui->maximumDepthText->setText(d ? get_depth_string(d->maxdepth, TRUE) : "");
|
||||
ui->averageDepthText->setText(d ? get_depth_string(d->meandepth, TRUE) : "");
|
||||
sacVal.mliter = d ? d->sac : 0;
|
||||
ui->sacText->setText(get_volume_string(sacVal, TRUE).append("/min"));
|
||||
ui->otuText->setText(QString("%1").arg( d ? d->otu : 0));
|
||||
ui->waterTemperatureText->setText(d ? get_temperature_string(d->watertemp, TRUE) : "");
|
||||
ui->airTemperatureText->setText(d ? get_temperature_string(d->airtemp, TRUE) : "");
|
||||
if (d && d->surface_pressure.mbar)
|
||||
/* this is ALWAYS displayed in mbar */
|
||||
ui->airPressureText->setText(QString("%1mbar").arg(d->surface_pressure.mbar));
|
||||
else
|
||||
ui->airPressureText->setText(QString(""));
|
||||
if (d)
|
||||
ui->maximumDepthText->setText(get_depth_string(d->maxdepth, TRUE));
|
||||
ui->averageDepthText->setText(get_depth_string(d->meandepth, TRUE));
|
||||
ui->otuText->setText(QString("%1").arg(d->otu));
|
||||
ui->waterTemperatureText->setText(get_temperature_string(d->watertemp, TRUE));
|
||||
ui->airTemperatureText->setText(get_temperature_string(d->airtemp, TRUE));
|
||||
ui->gasUsedText->setText(get_volume_string(get_gas_used(d), TRUE));
|
||||
else
|
||||
ui->gasUsedText->setText("");
|
||||
if ((sacVal.mliter = d->sac) > 0)
|
||||
ui->sacText->setText(get_volume_string(sacVal, TRUE).append("/min"));
|
||||
else
|
||||
ui->sacText->setText(QString());
|
||||
if (d->surface_pressure.mbar)
|
||||
/* this is ALWAYS displayed in mbar */
|
||||
ui->airPressureText->setText(QString("%1mbar").arg(d->surface_pressure.mbar));
|
||||
else
|
||||
ui->airPressureText->setText(QString());
|
||||
} else {
|
||||
ui->rating->setCurrentStars(0);
|
||||
ui->sacText->setText(QString());
|
||||
ui->otuText->setText(QString());
|
||||
ui->oxygenHeliumText->setText(QString());
|
||||
ui->dateText->setText(QString());
|
||||
ui->diveTimeText->setText(QString());
|
||||
ui->surfaceIntervalText->setText(QString());
|
||||
ui->maximumDepthText->setText(QString());
|
||||
ui->averageDepthText->setText(QString());
|
||||
ui->visibilityText->setText(QString());
|
||||
ui->waterTemperatureText->setText(QString());
|
||||
ui->airTemperatureText->setText(QString());
|
||||
ui->gasUsedText->setText(QString());
|
||||
ui->airPressureText->setText(QString());
|
||||
}
|
||||
}
|
||||
|
||||
void MainTab::on_addCylinder_clicked()
|
||||
|
|
Loading…
Add table
Reference in a new issue