From 7646f13ca808cb1d993176a739bd324bd0743fa1 Mon Sep 17 00:00:00 2001 From: Hugo Saint-Vignes Date: Thu, 10 Dec 2020 18:09:56 +0100 Subject: [PATCH] [apps/shared] Fix NaN comparison in isCursorHanging method --- apps/shared/function_graph_controller.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/shared/function_graph_controller.cpp b/apps/shared/function_graph_controller.cpp index 1f59575c3..528013d4d 100644 --- a/apps/shared/function_graph_controller.cpp +++ b/apps/shared/function_graph_controller.cpp @@ -130,7 +130,9 @@ bool FunctionGraphController::isCursorHanging() { } ExpiringPointer f = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(indexFunctionSelectedByCursor())); Coordinate2D xy = f->evaluateXYAtParameter(m_cursor->t(), context); - 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()))); } CurveView * FunctionGraphController::curveView() {