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>
This commit is contained in:
Dirk Hohndel 2021-01-03 16:57:59 -08:00
parent 6a6dd0888a
commit 1f1d82b1b3

View file

@ -65,8 +65,11 @@ 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());
if (chart) {
connect(chart, &QtCharts::QChart::plotAreaChanged, this, &StatsView::plotAreaChanged);
connect(&diveListNotifier, &DiveListNotifier::numShownChanged, this, &StatsView::replotIfVisible);
@ -74,6 +77,7 @@ StatsView::StatsView(QWidget *parent) : QQuickWidget(parent),
chart->setAcceptHoverEvents(true);
chart->legend()->setVisible(false);
}
}
StatsView::~StatsView()
{