[PATCH] Fix crash on right click dive trip.
Amit Chaudhuri
amit.k.chaudhuri at gmail.com
Wed May 8 12:31:40 PDT 2013
Dirk,
not always ;(
patch looks good, compiles and seems to fix. Also looks better as you
wound some of the adjacent clauses into one control block.
A
On Wed, May 8, 2013 at 8:16 PM, Dirk Hohndel <dirk at hohndel.org> wrote:
>
> You don't check what's in git before you work on patches, do you? :-)
>
> I already had something else committed, but I realized that you were
> working in a cleaner direction so I took this patch, massaged it a bit
> and added it on top of mine.
>
> Please check the Qt branch to make sure I didn't break anything
>
> /D
>
> On Wed, 2013-05-08 at 19:38 +0100, amit.k.chaudhuri at gmail.com wrote:
> > 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 to avoid crash and clear dive info widget text labels.
> >
> > Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri at gmail.com>
> > ---
> > qt-ui/maintab.cpp | 28 +++++++++++++++++++++-------
> > 1 file changed, 21 insertions(+), 7 deletions(-)
> >
> > diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
> > index 89501fc..3734aba 100644
> > --- a/qt-ui/maintab.cpp
> > +++ b/qt-ui/maintab.cpp
> > @@ -91,13 +91,27 @@ 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) : "");
> > + } else {
> > + 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());
> > + }
> > if (d && d->surface_pressure.mbar)
> > /* this is ALWAYS displayed in mbar */
> >
> ui->airPressureText->setText(QString("%1mbar").arg(d->surface_pressure.mbar));
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20130508/b43b4676/attachment-0001.html>
More information about the subsurface
mailing list