From 9443fcb0432144eadd57b3302e79d384b4491046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Wed, 24 Jan 2018 15:02:53 +0100 Subject: [PATCH] [apps] Sequence: in the toolbox, update the extra-cells when updating the hold layout to avoid unvalid read --- apps/sequence/list/sequence_toolbox.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/sequence/list/sequence_toolbox.cpp b/apps/sequence/list/sequence_toolbox.cpp index 708e670d6..f46eab7d1 100644 --- a/apps/sequence/list/sequence_toolbox.cpp +++ b/apps/sequence/list/sequence_toolbox.cpp @@ -52,11 +52,7 @@ HighlightCell * SequenceToolbox::reusableCell(int index, int type) { } void SequenceToolbox::willDisplayCellForIndex(HighlightCell * cell, int index) { - if (typeAtLocation(0, index) == 2) { - ExpressionTableCell * myCell = (ExpressionTableCell *)cell; - myCell->setExpression(m_addedCellLayout[index]); - return; - } else { + if (typeAtLocation(0, index) != 2) { MathToolbox::willDisplayCellForIndex(cell, mathToolboxIndex(index)); } } @@ -98,6 +94,9 @@ void SequenceToolbox::setExtraCells(const char * sequenceName, int recurrenceDep const char * indice = recurrenceDepth == 0 ? "n" : (recurrenceDepth == 1 ? "n+1" : "n+2"); m_addedCellLayout[2*recurrenceDepth] = new BaselineRelativeLayout(new StringLayout(otherSequenceName, 1, KDText::FontSize::Large), new StringLayout(indice, strlen(indice), KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript); } + for (int index = 0; index < k_maxNumberOfDisplayedRows; index++) { + m_addedCells[index].setExpression(m_addedCellLayout[index]); + } } bool SequenceToolbox::selectAddedCell(int selectedRow){