diff --git a/escher/src/expression_view.cpp b/escher/src/expression_view.cpp index 35f0f65cf..75dab0d4e 100644 --- a/escher/src/expression_view.cpp +++ b/escher/src/expression_view.cpp @@ -18,13 +18,11 @@ ExpressionView::ExpressionView(float horizontalAlignment, float verticalAlignmen } bool ExpressionView::setLayout(Layout layoutR) { - /* TODO: this would avoid some useless redrawing. However, when we call - * setLayout after raising an Exception that led to erase all - * Poincare::TreePool, accessing m_layout will result in an ACCESS ERROR. - * How do we avoid that? */ - /*if (m_layout.isIdenticalTo(layoutR)) { + if (!m_layout.wasErasedByException() && m_layout.isIdenticalTo(layoutR)) { + /* Check m_layout.wasErasedByException(), otherwise accessing m_layout would + * result in an ACCESS ERROR. */ return false; - }*/ + } m_layout = layoutR; markRectAsDirty(bounds()); return true; diff --git a/poincare/include/poincare/tree_handle.h b/poincare/include/poincare/tree_handle.h index b171871b6..30aea87fd 100644 --- a/poincare/include/poincare/tree_handle.h +++ b/poincare/include/poincare/tree_handle.h @@ -62,6 +62,9 @@ public: uint16_t identifier() const { return m_identifier; } TreeNode * node() const; + bool wasErasedByException() const { + return hasNode(m_identifier) && node() == nullptr; + } int nodeRetainCount() const { return node()->retainCount(); } size_t size() const; void * addressInPool() const { return reinterpret_cast(node()); }