diff --git a/apps/sequence/sequence.cpp b/apps/sequence/sequence.cpp index 63bbf7cb9..d5f6cd2af 100644 --- a/apps/sequence/sequence.cpp +++ b/apps/sequence/sequence.cpp @@ -63,13 +63,21 @@ Sequence::~Sequence() { } Sequence& Sequence::operator=(const Sequence& other) { - // Self-assignment is benign + /* We temporarely store other's required features to be able to access them + * after setType (which erase all contents and index buffer) even in case of + * self assignement */ + const char * contentText = other.text(); + const char * firstInitialText = other.m_firstInitialConditionText; + const char * secondInitialText = other.m_secondInitialConditionText; + int indexBuffer0 = other.m_indexBuffer[0]; + int indexBuffer1 = other.m_indexBuffer[1]; Function::operator=(other); setType(other.m_type); - setFirstInitialConditionContent(other.m_firstInitialConditionText); - setSecondInitialConditionContent(other.m_secondInitialConditionText); - m_indexBuffer[0] = other.m_indexBuffer[0]; - m_indexBuffer[1] = other.m_indexBuffer[1]; + setContent(contentText); + setFirstInitialConditionContent(firstInitialText); + setSecondInitialConditionContent(secondInitialText); + m_indexBuffer[0] = indexBuffer0; + m_indexBuffer[1] = indexBuffer1; return *this; } diff --git a/apps/shared/function.cpp b/apps/shared/function.cpp index 6cdc5afef..6b84b1114 100644 --- a/apps/shared/function.cpp +++ b/apps/shared/function.cpp @@ -55,7 +55,7 @@ Function::~Function() { } } -const char * Function::text() { +const char * Function::text() const { return m_text; } diff --git a/apps/shared/function.h b/apps/shared/function.h index 2de7b2931..c7b6e0a37 100644 --- a/apps/shared/function.h +++ b/apps/shared/function.h @@ -15,7 +15,7 @@ public: Function& operator=(Function&& other) = delete; Function(const Function& other) = delete; Function(Function&& other) = delete; - const char * text(); + const char * text() const; const char * name() const; KDColor color() const { return m_color; } Poincare::Expression * expression();