mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/calculation] Apply fix about Height computation
There was a problem with the way of computing Height, see Calculation::HistoryViewCell. We did not encounter a problemeatic scenario here, but there is no reason it would have been safe before.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "illustrated_list_controller.h"
|
||||
#include <poincare/exception_checkpoint.h>
|
||||
#include <poincare/symbol.h>
|
||||
#include "../app.h"
|
||||
|
||||
@@ -82,6 +83,10 @@ KDCoordinate IllustratedListController::rowHeight(int j) {
|
||||
KDCoordinate result = calculation->memoizedHeight(expanded);
|
||||
if (result < 0) {
|
||||
result = ScrollableThreeExpressionsCell::Height(calculation.pointer());
|
||||
if (result < 0) {
|
||||
// Raise, because Height modified the calculation and failed.
|
||||
Poincare::ExceptionCheckpoint::Raise();
|
||||
}
|
||||
calculation->setMemoizedHeight(expanded, result);
|
||||
}
|
||||
return result + Metric::CellSeparatorThickness;
|
||||
|
||||
@@ -8,7 +8,8 @@ void ScrollableThreeExpressionsView::resetMemoization() {
|
||||
setLayouts(Poincare::Layout(), Poincare::Layout(), Poincare::Layout());
|
||||
}
|
||||
|
||||
void ScrollableThreeExpressionsView::setCalculation(Calculation * calculation) {
|
||||
void ScrollableThreeExpressionsView::setCalculation(Calculation * calculation, bool * didForceOutput) {
|
||||
assert(!didForceOutput || *didForceOutput == false);
|
||||
Poincare::Context * context = App::app()->localContext();
|
||||
|
||||
// Clean the layouts to make room in the pool
|
||||
@@ -27,6 +28,9 @@ void ScrollableThreeExpressionsView::setCalculation(Calculation * calculation) {
|
||||
Poincare::ExceptionCheckpoint::Raise();
|
||||
} else {
|
||||
calculation->forceDisplayOutput(::Calculation::Calculation::DisplayOutput::ApproximateOnly);
|
||||
if (didForceOutput) {
|
||||
*didForceOutput = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,6 +50,9 @@ void ScrollableThreeExpressionsView::setCalculation(Calculation * calculation) {
|
||||
/* Set the display output to ApproximateOnly, make room in the pool by
|
||||
* erasing the exact layout, and retry to create the approximate layout */
|
||||
calculation->forceDisplayOutput(::Calculation::Calculation::DisplayOutput::ApproximateOnly);
|
||||
if (didForceOutput) {
|
||||
*didForceOutput = true;
|
||||
}
|
||||
exactOutputLayout = Poincare::Layout();
|
||||
couldNotCreateApproximateLayout = false;
|
||||
approximateOutputLayout = calculation->createApproximateOutputLayout(context, &couldNotCreateApproximateLayout);
|
||||
@@ -67,7 +74,16 @@ void ScrollableThreeExpressionsView::setCalculation(Calculation * calculation) {
|
||||
|
||||
KDCoordinate ScrollableThreeExpressionsCell::Height(Calculation * calculation) {
|
||||
ScrollableThreeExpressionsCell cell;
|
||||
cell.setCalculation(calculation);
|
||||
bool didForceOutput = false;
|
||||
cell.setCalculation(calculation, &didForceOutput);
|
||||
if (didForceOutput) {
|
||||
/* We could not compute the height of the calculation as it is (the display
|
||||
* output was forced to another value during the height computation).
|
||||
* Warning: the display output of calculation was actually changed, so it
|
||||
* will cause problems if we already did some computations with another
|
||||
* display value. */
|
||||
return -1;
|
||||
}
|
||||
KDRect leftFrame = KDRectZero;
|
||||
KDRect centerFrame = KDRectZero;
|
||||
KDRect approximateSignFrame = KDRectZero;
|
||||
@@ -87,8 +103,8 @@ void ScrollableThreeExpressionsCell::reinitSelection() {
|
||||
m_view.reloadScroll();
|
||||
}
|
||||
|
||||
void ScrollableThreeExpressionsCell::setCalculation(Calculation * calculation) {
|
||||
m_view.setCalculation(calculation);
|
||||
void ScrollableThreeExpressionsCell::setCalculation(Calculation * calculation, bool * didForceOutput) {
|
||||
m_view.setCalculation(calculation, didForceOutput);
|
||||
layoutSubviews();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
setBackgroundColor(KDColorWhite);
|
||||
}
|
||||
void resetMemoization();
|
||||
void setCalculation(Calculation * calculation);
|
||||
void setCalculation(Calculation * calculation, bool * didForceOutput = nullptr);
|
||||
void subviewFrames(KDRect * leftFrame, KDRect * centerFrame, KDRect * approximateSignFrame, KDRect * rightFrame) {
|
||||
return m_contentCell.subviewFrames(leftFrame, centerFrame, approximateSignFrame, rightFrame);
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
|
||||
void setHighlighted(bool highlight) override { m_view.evenOddCell()->setHighlighted(highlight); }
|
||||
void resetMemoization() { m_view.resetMemoization(); }
|
||||
void setCalculation(Calculation * calculation);
|
||||
void setCalculation(Calculation * calculation, bool * didForceOutput = nullptr);
|
||||
void setDisplayCenter(bool display);
|
||||
ScrollableThreeExpressionsView::SubviewPosition selectedSubviewPosition() { return m_view.selectedSubviewPosition(); }
|
||||
void setSelectedSubviewPosition(ScrollableThreeExpressionsView::SubviewPosition subviewPosition) { m_view.setSelectedSubviewPosition(subviewPosition); }
|
||||
|
||||
Reference in New Issue
Block a user