From 26bbdead7d9b9f8fb22c7f26abb3b8c7c84e5f2c Mon Sep 17 00:00:00 2001 From: Gabriel Ozouf Date: Thu, 17 Sep 2020 17:43:30 +0200 Subject: [PATCH] [apps/shared] Allow movement from undef curve Fix a bug preventing the cursor from moving to other curves using UP and DOWN when the y value was undef. To reproduce : - In Graph, define f(x) = 1 and g(x) = ln(x), then draw the curves - Press DOWN to select g - Press LEFT until g is not defined anymore --> Pressing UP or DOWN won't allow you to select f Change-Id: I79ed4a57b78ac0b8dac3f66e722e358bd4be18d9 --- apps/shared/interactive_curve_view_controller.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/shared/interactive_curve_view_controller.cpp b/apps/shared/interactive_curve_view_controller.cpp index 9e4c2ebed..20bac5311 100644 --- a/apps/shared/interactive_curve_view_controller.cpp +++ b/apps/shared/interactive_curve_view_controller.cpp @@ -261,6 +261,9 @@ bool InteractiveCurveViewController::isCursorVisible() { int InteractiveCurveViewController::closestCurveIndexVertically(bool goingUp, int currentCurveIndex, Poincare::Context * context) const { double x = m_cursor->x(); double y = m_cursor->y(); + if (std::isnan(y)) { + y = goingUp ? -INFINITY : INFINITY; + } double nextY = goingUp ? DBL_MAX : -DBL_MAX; int nextCurveIndex = -1; int curvesCount = numberOfCurves();