From b7bbb258a87ac3901c48e0311fb319b5bd6b21ab Mon Sep 17 00:00:00 2001 From: Hugo Saint-Vignes Date: Wed, 16 Dec 2020 14:09:54 +0100 Subject: [PATCH] [apps/regression] Fix NaN comparison in isCursorHanging method --- apps/regression/graph_controller.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/regression/graph_controller.cpp b/apps/regression/graph_controller.cpp index 6ccc4f1f4..a6934e328 100644 --- a/apps/regression/graph_controller.cpp +++ b/apps/regression/graph_controller.cpp @@ -271,7 +271,9 @@ bool GraphController::isCursorHanging() { } else { xy = Coordinate2D(m_store->get(*m_selectedSeriesIndex, 0, *m_selectedDotIndex), m_store->get(*m_selectedSeriesIndex, 1, *m_selectedDotIndex)); } - return xy.x1() != m_cursor->x() || xy.x2() != m_cursor->y(); + // NaN != Nan returns true, but cursor is not hanging if both values are NaN + return (xy.x1() != m_cursor->x() && !(std::isnan(xy.x1()) && std::isnan(m_cursor->x()))) + || (xy.x2() != m_cursor->y() && !(std::isnan(xy.x2()) && std::isnan(m_cursor->y()))); } bool GraphController::moveCursorVertically(int direction) {