[apps/calculation] The heights (common and expanded) of calculation cells are

computed when the calculation is added to the store and don't change afterwards.
Otherwise, if their heights change when scrolling (due to a modification of the
display output type - ExactOnly, ApproximateOnly...), it generates crashes.
This commit is contained in:
Émilie Feral
2020-07-16 11:29:52 +02:00
committed by LeaNumworks
parent c2db00cc88
commit df74c2c551
14 changed files with 65 additions and 111 deletions

View File

@@ -206,20 +206,7 @@ KDCoordinate HistoryController::rowHeight(int j) {
}
Shared::ExpiringPointer<Calculation> calculation = calculationAtIndex(j);
bool expanded = j == selectedRow() && selectedSubviewType() == SubviewType::Output;
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:
* assert(result == HistoryViewCell::Height(calculation.pointer(), expanded));
* However, Height might fail due to pool memory exhaustion, in which case the
* assertion fails even if "result" had the right value. */
return result;
return calculation->height(expanded);
}
int HistoryController::typeAtLocation(int i, int j) {