[apps/calculation] HistoryController: pointer to Calculation are expring

pointer, they've to be recomputed everytime we reload the table (because
of a scroll or when deselecting the table)
This commit is contained in:
Émilie Feral
2020-01-08 16:39:37 +01:00
committed by Léa Saviot
parent eb4a36696a
commit 1f4b823509

View File

@@ -60,12 +60,11 @@ bool HistoryController::handleEvent(Ion::Events::Event event) {
int focusRow = selectedRow();
HistoryViewCell * selectedCell = (HistoryViewCell *)m_selectableTableView.selectedCell();
SubviewType subviewType = selectedSubviewType();
Shared::ExpiringPointer<Calculation> calculation = calculationAtIndex(focusRow);
EditExpressionController * editController = (EditExpressionController *)parentResponder();
if (subviewType == SubviewType::Input) {
m_selectableTableView.deselectTable();
Container::activeApp()->setFirstResponder(editController);
editController->insertTextBody(calculation->inputText());
editController->insertTextBody(calculationAtIndex(focusRow)->inputText());
} else {
ScrollableExactApproximateExpressionsView::SubviewPosition outputSubviewPosition = selectedCell->outputView()->selectedSubviewPosition();
if (outputSubviewPosition == ScrollableExactApproximateExpressionsView::SubviewPosition::Left) {
@@ -81,12 +80,13 @@ bool HistoryController::handleEvent(Ion::Events::Event event) {
vc = &m_rationalController;
}
if (vc) {
vc->setExpression(calculation->input());
vc->setExpression(calculationAtIndex(focusRow)->input());
Container::activeApp()->displayModalViewController(vc, 0.f, 0.f, Metric::CommonTopMargin, Metric::PopUpLeftMargin, 0, Metric::PopUpRightMargin);
}
} else {
m_selectableTableView.deselectTable();
Container::activeApp()->setFirstResponder(editController);
Shared::ExpiringPointer<Calculation> calculation = calculationAtIndex(focusRow);
if (outputSubviewPosition == ScrollableExactApproximateExpressionsView::SubviewPosition::Right
&& !calculation->shouldOnlyDisplayExactOutput())
{