diff --git a/apps/calculation/calculation.cpp b/apps/calculation/calculation.cpp index 504e74d1e..fe1d36de1 100644 --- a/apps/calculation/calculation.cpp +++ b/apps/calculation/calculation.cpp @@ -33,6 +33,13 @@ Calculation * Calculation::next() const { return reinterpret_cast(const_cast(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; diff --git a/apps/calculation/calculation.h b/apps/calculation/calculation.h index c9d23c9f1..9e5b9b85a 100644 --- a/apps/calculation/calculation.h +++ b/apps/calculation/calculation.h @@ -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; } diff --git a/apps/calculation/calculation_store.cpp b/apps/calculation/calculation_store.cpp index be2148b27..472889d66 100644 --- a/apps/calculation/calculation_store.cpp +++ b/apps/calculation/calculation_store.cpp @@ -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); diff --git a/apps/calculation/calculation_store.h b/apps/calculation/calculation_store.h index c3f8cf876..b21685fd8 100644 --- a/apps/calculation/calculation_store.h +++ b/apps/calculation/calculation_store.h @@ -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;