From fccd72b7573f10531637fc2042e0f231e8fb458d Mon Sep 17 00:00:00 2001 From: Ruben Dashyan Date: Mon, 2 Mar 2020 14:54:37 +0100 Subject: [PATCH] [apps/sequence/sequence] Do not memoize nameLayout Fixes the following bug: In the graph tab of the Sequence app, compute the sum of the terms of a sequence from 1 to 9 and then from 1 to 10. The Layout is memoized after the first time and mispositioned the second time since it is not recomputed. --- apps/sequence/sequence.cpp | 12 ++++-------- apps/sequence/sequence.h | 6 +++--- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/apps/sequence/sequence.cpp b/apps/sequence/sequence.cpp index e97f8d390..64643ace1 100644 --- a/apps/sequence/sequence.cpp +++ b/apps/sequence/sequence.cpp @@ -28,7 +28,6 @@ void Sequence::tidy() { m_firstInitialCondition.tidyName(); m_secondInitialCondition.tidy(); m_secondInitialCondition.tidyName(); - m_nameLayout = Layout(); } Sequence::Type Sequence::type() const { @@ -81,13 +80,10 @@ void Sequence::setInitialRank(int rank) { } Poincare::Layout Sequence::nameLayout() { - if (m_nameLayout.isUninitialized()) { - m_nameLayout = HorizontalLayout::Builder( - CodePointLayout::Builder(fullName()[0], KDFont::SmallFont), - VerticalOffsetLayout::Builder(CodePointLayout::Builder(symbol(), KDFont::SmallFont), VerticalOffsetLayoutNode::Position::Subscript) - ); - } - return m_nameLayout; + return HorizontalLayout::Builder( + CodePointLayout::Builder(fullName()[0], KDFont::SmallFont), + VerticalOffsetLayout::Builder(CodePointLayout::Builder(symbol(), KDFont::SmallFont), VerticalOffsetLayoutNode::Position::Subscript) + ); } bool Sequence::isDefined() { diff --git a/apps/sequence/sequence.h b/apps/sequence/sequence.h index e7901de68..d5b5c56a5 100644 --- a/apps/sequence/sequence.h +++ b/apps/sequence/sequence.h @@ -24,8 +24,9 @@ public: DoubleRecurrence = 2 }; Sequence(Ion::Storage::Record record = Record()) : - Function(record), - m_nameLayout() {} + Function(record) + { + } I18n::Message parameterMessageName() const override; CodePoint symbol() const override { return 'n'; } void tidy() override; @@ -153,7 +154,6 @@ private: DefinitionModel m_definition; FirstInitialConditionModel m_firstInitialCondition; SecondInitialConditionModel m_secondInitialCondition; - Poincare::Layout m_nameLayout; }; }