summaryrefslogtreecommitdiffstats
path: root/stats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2021-01-03 16:57:59 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-01-03 16:58:01 -0800
commit1f1d82b1b3fa1feb76f86eaf3bee3dfef9d62dbe (patch)
treeb5bf89a2c907f2f0ee599f3870f9fe6475e0b9f8 /stats
parent6a6dd0888ad91ff85a580c12d469afff1789788e (diff)
downloadsubsurface-1f1d82b1b3fa1feb76f86eaf3bee3dfef9d62dbe.tar.gz
statistics: don't crash if the QCharts QML modules aren't found
We don't really give a user visible error message which is kind of a problem, but at least we don't crash anymore. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'stats')
-rw-r--r--stats/statsview.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/stats/statsview.cpp b/stats/statsview.cpp
index 490e37385..6dd858e96 100644
--- a/stats/statsview.cpp
+++ b/stats/statsview.cpp
@@ -65,14 +65,18 @@ StatsView::StatsView(QWidget *parent) : QQuickWidget(parent),
eventFilter(this)
{
setResizeMode(QQuickWidget::SizeRootObjectToView);
+ // if we get a failure to load the QML file (e.g., when the QtCharts QML modules aren't found)
+ // the chart will be null
setSource(urlStatsView);
chart = getChart(rootObject());
- connect(chart, &QtCharts::QChart::plotAreaChanged, this, &StatsView::plotAreaChanged);
- connect(&diveListNotifier, &DiveListNotifier::numShownChanged, this, &StatsView::replotIfVisible);
+ if (chart) {
+ connect(chart, &QtCharts::QChart::plotAreaChanged, this, &StatsView::plotAreaChanged);
+ connect(&diveListNotifier, &DiveListNotifier::numShownChanged, this, &StatsView::replotIfVisible);
- chart->installEventFilter(&eventFilter);
- chart->setAcceptHoverEvents(true);
- chart->legend()->setVisible(false);
+ chart->installEventFilter(&eventFilter);
+ chart->setAcceptHoverEvents(true);
+ chart->legend()->setVisible(false);
+ }
}
StatsView::~StatsView()