Merge branch Tree into master

This commit is contained in:
Léa Saviot
2018-07-19 14:01:02 +02:00
219 changed files with 7627 additions and 765 deletions

View File

@@ -11,16 +11,15 @@ namespace Shared {
ExpressionModel::ExpressionModel() :
m_text{0},
m_expression(nullptr),
m_layout(nullptr)
m_layoutRef(nullptr)
{
}
ExpressionModel::~ExpressionModel() {
/* We cannot call tidy here because tidy is a virtual function and does not
* do the same thing for all children class. */
if (m_layout != nullptr) {
delete m_layout;
m_layout = nullptr;
if (m_layoutRef.isDefined()) {
m_layoutRef = LayoutRef(nullptr);
}
if (m_expression != nullptr) {
delete m_expression;
@@ -45,15 +44,15 @@ Poincare::Expression * ExpressionModel::expression(Poincare::Context * context)
return m_expression;
}
Poincare::ExpressionLayout * ExpressionModel::layout() {
if (m_layout == nullptr) {
LayoutRef ExpressionModel::layoutRef() {
if (!m_layoutRef.isDefined()) {
Expression * nonSimplifiedExpression = Expression::parse(m_text);
if (nonSimplifiedExpression != nullptr) {
m_layout = PoincareHelpers::CreateLayout(nonSimplifiedExpression);
m_layoutRef = PoincareHelpers::CreateLayout(nonSimplifiedExpression);
delete nonSimplifiedExpression;
}
}
return m_layout;
return m_layoutRef;
}
bool ExpressionModel::isDefined() {
@@ -69,9 +68,8 @@ void ExpressionModel::setContent(const char * c) {
/* We cannot call tidy here because tidy is a virtual function and does not
* do the same thing for all children class. And here we want to delete only
* the m_layout and m_expression. */
if (m_layout != nullptr) {
delete m_layout;
m_layout = nullptr;
if (m_layoutRef.isDefined()) {
m_layoutRef = LayoutRef(nullptr);
}
if (m_expression != nullptr) {
delete m_expression;
@@ -80,9 +78,8 @@ void ExpressionModel::setContent(const char * c) {
}
void ExpressionModel::tidy() {
if (m_layout != nullptr) {
delete m_layout;
m_layout = nullptr;
if (m_layoutRef.isDefined()) {
m_layoutRef = LayoutRef(nullptr);
}
if (m_expression != nullptr) {
delete m_expression;