From 32a5685e5cdea62ef7f4ece106b254d57df862ea Mon Sep 17 00:00:00 2001 From: rinkk <karsten.rink@ufz.de> Date: Thu, 2 Aug 2018 16:28:24 +0200 Subject: [PATCH] added more checks and fixed another warning --- .../DataExplorer/DataView/DiagramView/DiagramList.cpp | 10 ++++++++-- .../DataExplorer/DataView/DiagramView/DiagramList.h | 4 ++-- .../DataView/DiagramView/DiagramPrefsDialog.cpp | 3 ++- .../DataExplorer/DataView/DiagramView/QArrow.cpp | 2 +- .../DataExplorer/DataView/DiagramView/QArrow.h | 2 +- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Applications/DataExplorer/DataView/DiagramView/DiagramList.cpp b/Applications/DataExplorer/DataView/DiagramView/DiagramList.cpp index 0f0b210e50a..46c992a80c7 100644 --- a/Applications/DataExplorer/DataView/DiagramView/DiagramList.cpp +++ b/Applications/DataExplorer/DataView/DiagramView/DiagramList.cpp @@ -304,8 +304,11 @@ void DiagramList::truncateToRange(QDateTime const& start, QDateTime const& end) update(); } -void DiagramList::setList(std::vector< std::pair<QDateTime, float> > coords) +void DiagramList::setList(std::vector<std::pair<QDateTime, float>> const& coords) { + if (coords.empty()) + return; + this->_startDate = coords[0].first; _coords.emplace_back(0.0f, coords[0].second); @@ -320,8 +323,11 @@ void DiagramList::setList(std::vector< std::pair<QDateTime, float> > coords) update(); } -void DiagramList::setList(std::vector< std::pair<float, float> > coords) +void DiagramList::setList(std::vector< std::pair<float, float> > const& coords) { + if (coords.empty()) + return; + this->_startDate = QDateTime(); std::size_t nCoords = coords.size(); for (std::size_t i = 0; i < nCoords; i++) diff --git a/Applications/DataExplorer/DataView/DiagramView/DiagramList.h b/Applications/DataExplorer/DataView/DiagramView/DiagramList.h index 734edd39d73..60114cadae3 100644 --- a/Applications/DataExplorer/DataView/DiagramView/DiagramList.h +++ b/Applications/DataExplorer/DataView/DiagramView/DiagramList.h @@ -124,7 +124,7 @@ public: * Sets the list of x/y-coordinates. * \param coords List of coordinates. */ - void setList(std::vector< std::pair<float, float> > coords); + void setList(std::vector< std::pair<float, float> > const& coords); /** * Sets the list of x/y-coordinates. @@ -132,7 +132,7 @@ public: * days from the first date (which is set as day 0) * \param coords List of coordinates. */ - void setList(std::vector< std::pair<QDateTime, float> > coords); + void setList(std::vector< std::pair<QDateTime, float> > const& coords); /// Specifies the unit of the x Axis. void setXUnit(QString unit) { _xUnit = unit; } diff --git a/Applications/DataExplorer/DataView/DiagramView/DiagramPrefsDialog.cpp b/Applications/DataExplorer/DataView/DiagramView/DiagramPrefsDialog.cpp index f55381614a3..48abe51c040 100644 --- a/Applications/DataExplorer/DataView/DiagramView/DiagramPrefsDialog.cpp +++ b/Applications/DataExplorer/DataView/DiagramView/DiagramPrefsDialog.cpp @@ -77,7 +77,8 @@ void DiagramPrefsDialog::accept() return; } - // data has been loaded + // Data has been loaded. + // If loading the other lists fails at least nothing terrible will happen. if (_list[0]->size() > 0) { bool window_is_empty(false); diff --git a/Applications/DataExplorer/DataView/DiagramView/QArrow.cpp b/Applications/DataExplorer/DataView/DiagramView/QArrow.cpp index 6ddb4f81652..e54f20f7a0d 100644 --- a/Applications/DataExplorer/DataView/DiagramView/QArrow.cpp +++ b/Applications/DataExplorer/DataView/DiagramView/QArrow.cpp @@ -117,7 +117,7 @@ void QArrow::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QW } /// Changes orientation of the arrow. -void QArrow::setAngle(float a) +void QArrow::setAngle(qreal a) { _arrowAngle = a; } diff --git a/Applications/DataExplorer/DataView/DiagramView/QArrow.h b/Applications/DataExplorer/DataView/DiagramView/QArrow.h index 85e11e17f4b..208fd333cd5 100644 --- a/Applications/DataExplorer/DataView/DiagramView/QArrow.h +++ b/Applications/DataExplorer/DataView/DiagramView/QArrow.h @@ -35,7 +35,7 @@ public: void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override; QRectF boundingRect() const override; - void setAngle(float a); + void setAngle(qreal a); void setLength(qreal l); private: -- GitLab