mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Profile: don't crash when there are no cylinders
TankItem would happily access a non-existing cylinder and crash. But freedives for example have no cylinders. Thus, handle that situation gracefully by exiting early if there is no cylinder. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
2d637f2528
commit
fd23c3d908
2 changed files with 4 additions and 6 deletions
|
@ -32,11 +32,6 @@ TankItem::TankItem(QObject *parent) :
|
||||||
hAxis = nullptr;
|
hAxis = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
TankItem::~TankItem()
|
|
||||||
{
|
|
||||||
free(pInfoEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TankItem::setData(DivePlotDataModel *model, struct plot_info *plotInfo, struct dive *d)
|
void TankItem::setData(DivePlotDataModel *model, struct plot_info *plotInfo, struct dive *d)
|
||||||
{
|
{
|
||||||
// If there is nothing to plot, quit early.
|
// If there is nothing to plot, quit early.
|
||||||
|
@ -93,6 +88,10 @@ void TankItem::modelDataChanged(const QModelIndex&, const QModelIndex&)
|
||||||
qDeleteAll(rects);
|
qDeleteAll(rects);
|
||||||
rects.clear();
|
rects.clear();
|
||||||
|
|
||||||
|
// Bail if there are no cylinders
|
||||||
|
if (displayed_dive.cylinders.nr <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
// get the information directly from the displayed_dive (the dc always exists)
|
// get the information directly from the displayed_dive (the dc always exists)
|
||||||
struct divecomputer *dc = get_dive_dc(&displayed_dive, dc_number);
|
struct divecomputer *dc = get_dive_dc(&displayed_dive, dc_number);
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ class TankItem : public QObject, public QGraphicsRectItem
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TankItem(QObject *parent = 0);
|
explicit TankItem(QObject *parent = 0);
|
||||||
~TankItem();
|
|
||||||
void setHorizontalAxis(DiveCartesianAxis *horizontal);
|
void setHorizontalAxis(DiveCartesianAxis *horizontal);
|
||||||
void setData(DivePlotDataModel *model, struct plot_info *plotInfo, struct dive *d);
|
void setData(DivePlotDataModel *model, struct plot_info *plotInfo, struct dive *d);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue