mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/calculation] Invalid calculation height memoization when leaving
the app. Fix wrong memoization: in calculation app input '[[1+i, 2][3,4]]', change the complex format to Polar, go back to the calculation app --> the calculation height was no recomputed despite the fact that the approximation output changed.
This commit is contained in:
@@ -33,6 +33,13 @@ Calculation * Calculation::next() const {
|
||||
return reinterpret_cast<Calculation *>(const_cast<char *>(result));
|
||||
}
|
||||
|
||||
void Calculation::tidy() {
|
||||
/* Reset height memoization (the complex format could have changed when
|
||||
* re-entering Calculation app which would impact the heights). */
|
||||
m_height = -1;
|
||||
m_expandedHeight = -1;
|
||||
}
|
||||
|
||||
const char * Calculation::approximateOutputText() const {
|
||||
const char * exactOutput = exactOutputText();
|
||||
return exactOutput + strlen(exactOutput) + 1;
|
||||
|
||||
@@ -50,6 +50,8 @@ public:
|
||||
bool operator==(const Calculation& c);
|
||||
Calculation * next() const;
|
||||
|
||||
void tidy();
|
||||
|
||||
// Texts
|
||||
const char * inputText() const { return m_inputText; }
|
||||
const char * exactOutputText() const { return m_inputText + strlen(m_inputText) + 1; }
|
||||
|
||||
@@ -141,6 +141,13 @@ void CalculationStore::deleteAll() {
|
||||
resetMemoizedModelsAfterCalculationIndex(-1);
|
||||
}
|
||||
|
||||
void CalculationStore::tidy() {
|
||||
resetMemoizedModelsAfterCalculationIndex(-1);
|
||||
for (Calculation * c : *this) {
|
||||
c->tidy();
|
||||
}
|
||||
}
|
||||
|
||||
Expression CalculationStore::ansExpression(Context * context) {
|
||||
if (numberOfCalculations() == 0) {
|
||||
return Rational::Builder(0);
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
void deleteAll();
|
||||
int numberOfCalculations() const { return m_numberOfCalculations; }
|
||||
Poincare::Expression ansExpression(Poincare::Context * context);
|
||||
void tidy() { resetMemoizedModelsAfterCalculationIndex(-1); }
|
||||
void tidy();
|
||||
private:
|
||||
static constexpr int k_bufferSize = 10 * 3 * Constant::MaxSerializedExpressionSize;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user