diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2014-09-20 13:41:36 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-09-20 18:35:08 -0700 |
commit | 2b760bdd394bafde3c2ed7fb3b8aa8c258db29cc (patch) | |
tree | f095695c29034223546e10778b4c8f31d677da42 /qt-ui/profile/divetooltipitem.cpp | |
parent | a2f27517922f5422e62e57f6ce1279b7235ce2fc (diff) | |
download | subsurface-2b760bdd394bafde3c2ed7fb3b8aa8c258db29cc.tar.gz |
Fix crash when moving the mouse over the profile when no dive is shown
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile/divetooltipitem.cpp')
-rw-r--r-- | qt-ui/profile/divetooltipitem.cpp | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/qt-ui/profile/divetooltipitem.cpp b/qt-ui/profile/divetooltipitem.cpp index 97f687ab0..33679d044 100644 --- a/qt-ui/profile/divetooltipitem.cpp +++ b/qt-ui/profile/divetooltipitem.cpp @@ -235,23 +235,25 @@ void ToolTipItem::refresh(const QPointF &pos) struct membuffer mb = { 0 }; entry = get_plot_details_new(&pInfo, time, &mb); - tissues->fill(); - painter->setPen(QColor(0, 0, 0, 0)); - painter->setBrush(QColor(LIMENADE1)); - painter->drawRect(0, 10 + (100 - AMB_PERCENTAGE) / 2, 16, AMB_PERCENTAGE / 2); - painter->setBrush(QColor(SPRINGWOOD1)); - painter->drawRect(0, 10, 16, (100 - AMB_PERCENTAGE) / 2); - painter->setBrush(QColor("Red")); - painter->drawRect(0,0,16,10); - painter->setPen(QColor(0, 0, 0, 255)); - painter->drawLine(0, 60 - entry->gfline / 2, 16, 60 - entry->gfline / 2); - painter->drawLine(0, 60 - AMB_PERCENTAGE * (entry->pressures.n2 + entry->pressures.he) / entry->ambpressure / 2, - 16, 60 - AMB_PERCENTAGE * (entry->pressures.n2 + entry->pressures.he) / entry->ambpressure /2); - painter->setPen(QColor(0, 0, 0, 127)); - for (i=0; i<16; i++) { - painter->drawLine(i, 60, i, 60 - entry->percentages[i] / 2); + if (entry) { + tissues->fill(); + painter->setPen(QColor(0, 0, 0, 0)); + painter->setBrush(QColor(LIMENADE1)); + painter->drawRect(0, 10 + (100 - AMB_PERCENTAGE) / 2, 16, AMB_PERCENTAGE / 2); + painter->setBrush(QColor(SPRINGWOOD1)); + painter->drawRect(0, 10, 16, (100 - AMB_PERCENTAGE) / 2); + painter->setBrush(QColor("Red")); + painter->drawRect(0,0,16,10); + painter->setPen(QColor(0, 0, 0, 255)); + painter->drawLine(0, 60 - entry->gfline / 2, 16, 60 - entry->gfline / 2); + painter->drawLine(0, 60 - AMB_PERCENTAGE * (entry->pressures.n2 + entry->pressures.he) / entry->ambpressure / 2, + 16, 60 - AMB_PERCENTAGE * (entry->pressures.n2 + entry->pressures.he) / entry->ambpressure /2); + painter->setPen(QColor(0, 0, 0, 127)); + for (i=0; i<16; i++) { + painter->drawLine(i, 60, i, 60 - entry->percentages[i] / 2); + } + addToolTip(QString::fromUtf8(mb.buffer, mb.len),QIcon(), tissues); } - addToolTip(QString::fromUtf8(mb.buffer, mb.len),QIcon(), tissues); free_buffer(&mb); Q_FOREACH (QGraphicsItem *item, scene()->items(pos, Qt::IntersectsItemShape |