diff --git a/apps/shared/function_graph_controller.cpp b/apps/shared/function_graph_controller.cpp index 36327d9da..6606ca059 100644 --- a/apps/shared/function_graph_controller.cpp +++ b/apps/shared/function_graph_controller.cpp @@ -140,13 +140,15 @@ void FunctionGraphController::initCursorParameters() { Coordinate2D xy; double t; do { - Ion::Storage::Record record = functionStore()->activeRecordAtIndex(functionIndex++); + Ion::Storage::Record record = functionStore()->activeRecordAtIndex(functionIndex); ExpiringPointer firstFunction = functionStore()->modelForRecord(record); t = defaultCursorT(record); xy = firstFunction->evaluateXYAtParameter(t, context); - } while ((std::isnan(xy.x2()) || std::isinf(xy.x2())) && functionIndex < activeFunctionsCount); + } while ((std::isnan(xy.x2()) || std::isinf(xy.x2())) && ++functionIndex < activeFunctionsCount); + if (functionIndex == activeFunctionsCount) { + functionIndex = 0; + } m_cursor->moveTo(t, xy.x1(), xy.x2()); - functionIndex = (std::isnan(xy.x2()) || std::isinf(xy.x2())) ? 0 : functionIndex - 1; selectFunctionWithCursor(functionIndex); if (interactiveCurveViewRange()->yAuto()) { interactiveCurveViewRange()->panToMakePointVisible(xy.x1(), xy.x2(), cursorTopMarginRatio(), k_cursorRightMarginRatio, cursorBottomMarginRatio(), k_cursorLeftMarginRatio);