[apps/calculation] Raise exception if row height miscomputed

Scenario:
Put the complex mode to exponential, then go back to Calculation and:
Toolbox, Down, Down, Down, Down, OK, OK, Two, Plus, Imaginary,
Toolbox, Down, Down, Down, Down, OK, Down, OK, Two, Plus,
Imaginary, OK, Toolbox, Down, Down, Down, Down, Down, OK,
Down, OK, Up, OK, Right, Zero, OK, OK, Toolbox, Down,
Down, OK, Toolbox, Back, Up, Zero, Up, OK, Zero, Up, Up, Up
This commit is contained in:
Léa Saviot
2020-07-06 17:26:06 +02:00
parent 924e235ba8
commit 1128134c37
3 changed files with 24 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
#include "history_controller.h"
#include "app.h"
#include <poincare/exception_checkpoint.h>
#include <assert.h>
using namespace Shared;
@@ -206,6 +207,10 @@ KDCoordinate HistoryController::rowHeight(int j) {
KDCoordinate result = calculation->memoizedHeight(expanded);
if (result < 0) {
result = HistoryViewCell::Height(calculation.pointer(), expanded);
if (result < 0) {
// Raise, because Height modified the calculation and failed.
Poincare::ExceptionCheckpoint::Raise();
}
calculation->setMemoizedHeight(expanded, result);
}
/* We might want to put an assertion here to check the memoization: