[PATCH] Fix crash on right click dive trip.
Tomaz Canabrava
tcanabrava at kde.org
Wed May 8 10:35:49 PDT 2013
why not a if (!d) return; ?
this way you don't need the second if to try too things, and the patch will
be smaller.
2013/5/8 <amit.k.chaudhuri at gmail.com>
> From: Amit Chaudhuri <amit.k.chaudhuri at gmail.com>
>
> 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 offending code with 'if (d)'
>
> Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri at gmail.com>
> ---
> qt-ui/maintab.cpp | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
> index 89501fc..bf351b6 100644
> --- a/qt-ui/maintab.cpp
> +++ b/qt-ui/maintab.cpp
> @@ -91,13 +91,15 @@ void MainTab::updateDiveInfo(int dive)
> ui->rating->setCurrentStars(d->rating);
> else
> ui->rating->setCurrentStars(0);
> - ui->maximumDepthText->setText(get_depth_string(d->maxdepth, TRUE));
> - ui->averageDepthText->setText(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) {
> +
> ui->maximumDepthText->setText(get_depth_string(d->maxdepth, TRUE));
> +
> ui->averageDepthText->setText(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));
> --
> 1.7.10.4
>
> _______________________________________________
> subsurface mailing list
> subsurface at hohndel.org
> http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20130508/e22a6dd8/attachment.html>
More information about the subsurface
mailing list