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();