diff --git a/apps/shared/function_graph_controller.cpp b/apps/shared/function_graph_controller.cpp index 02b2a9212..36327d9da 100644 --- a/apps/shared/function_graph_controller.cpp +++ b/apps/shared/function_graph_controller.cpp @@ -135,6 +135,7 @@ FunctionStore * FunctionGraphController::functionStore() const { void FunctionGraphController::initCursorParameters() { Poincare::Context * context = textFieldDelegateApp()->localContext(); + const int activeFunctionsCount = functionStore()->numberOfActiveFunctions(); int functionIndex = 0; Coordinate2D xy; double t; @@ -143,7 +144,7 @@ void FunctionGraphController::initCursorParameters() { ExpiringPointer firstFunction = functionStore()->modelForRecord(record); t = defaultCursorT(record); xy = firstFunction->evaluateXYAtParameter(t, context); - } while ((std::isnan(xy.x2()) || std::isinf(xy.x2())) && functionIndex < functionStore()->numberOfActiveFunctions()); + } while ((std::isnan(xy.x2()) || std::isinf(xy.x2())) && functionIndex < activeFunctionsCount); m_cursor->moveTo(t, xy.x1(), xy.x2()); functionIndex = (std::isnan(xy.x2()) || std::isinf(xy.x2())) ? 0 : functionIndex - 1; selectFunctionWithCursor(functionIndex);