[apps/sequence] Fix error in copy assignment of sequence

Change-Id: If27924c6001a8d7011371336ffbaf012f9d8bbc9
This commit is contained in:
Émilie Feral
2017-05-10 11:33:25 +02:00
parent 0b9abfa869
commit e5dd0d8d7f
3 changed files with 15 additions and 7 deletions

View File

@@ -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;
}

View File

@@ -55,7 +55,7 @@ Function::~Function() {
}
}
const char * Function::text() {
const char * Function::text() const {
return m_text;
}

View File

@@ -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();