From 17e0fcc29e21e34aec65aeb85029bdc745b620f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Mon, 28 May 2018 14:24:19 +0200 Subject: [PATCH] [apps/stats] Fix CalculationController::indexFromCumulatedWidth --- apps/statistics/calculation_controller.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/statistics/calculation_controller.cpp b/apps/statistics/calculation_controller.cpp index 9fa60eb53..b368f493f 100644 --- a/apps/statistics/calculation_controller.cpp +++ b/apps/statistics/calculation_controller.cpp @@ -110,8 +110,8 @@ KDCoordinate CalculationController::cumulatedHeightFromIndex(int j) { int CalculationController::indexFromCumulatedWidth(KDCoordinate offsetX) { int result = 0; int i = 0; - while (result < offsetX && i < numberOfRows()) { - result += rowHeight(i++); + while (result < offsetX && i < numberOfColumns()) { + result += columnWidth(i++); } return (result < offsetX || offsetX == 0) ? i : i - 1; } @@ -150,6 +150,8 @@ int CalculationController::reusableCellCount(int type) { } int CalculationController::typeAtLocation(int i, int j) { + assert(i >= 0 && i < numberOfColumns()); + assert(j >= 0 && j < numberOfRows()); if (i == 0 && j == 0) { return k_hideableCellType; }