From a1de3c956cc851eacec624b1a54912974bf82053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sun, 27 Oct 2019 19:53:32 +0100 Subject: [PATCH] Fixed broken graphs with missing time data handling --- src/GUI/graphitem.cpp | 3 ++- src/GUI/graphview.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/GUI/graphitem.cpp b/src/GUI/graphitem.cpp index b463321f..3bebeec9 100644 --- a/src/GUI/graphitem.cpp +++ b/src/GUI/graphitem.cpp @@ -234,7 +234,8 @@ void GraphItem::updateBounds() } } - _bounds = QRectF(QPointF(left, top), QPointF(right, bottom)); + QRectF bounds(QPointF(left, top), QPointF(right, bottom)); + _bounds = bounds.isValid() ? bounds : QRectF(); } qreal GraphItem::max() const diff --git a/src/GUI/graphview.cpp b/src/GUI/graphview.cpp index a48121e4..54302690 100644 --- a/src/GUI/graphview.cpp +++ b/src/GUI/graphview.cpp @@ -166,6 +166,10 @@ void GraphView::setGraphType(GraphType type) for (int i = 0; i < _graphs.count(); i++) { GraphItem *gi = _graphs.at(i); gi->setGraphType(type); + if (gi->bounds().isNull()) + removeItem(gi); + else + addItem(gi); _bounds |= gi->bounds(); } @@ -194,7 +198,8 @@ void GraphView::addGraph(GraphItem *graph) SLOT(emitSliderPositionChanged(qreal))); _graphs.append(graph); - _scene->addItem(graph); + if (!graph->bounds().isNull()) + _scene->addItem(graph); _bounds |= graph->bounds(); setXUnits();