From d84a081e7eb6ed7fac53ec92b36670a34be5e245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Wed, 1 Aug 2018 10:44:22 +0200 Subject: [PATCH] [poincare] Clean EmptyLayoutNode::willAddSibling --- poincare/src/empty_layout_node.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/poincare/src/empty_layout_node.cpp b/poincare/src/empty_layout_node.cpp index a22e569e9..52da04bcc 100644 --- a/poincare/src/empty_layout_node.cpp +++ b/poincare/src/empty_layout_node.cpp @@ -75,19 +75,17 @@ bool EmptyLayoutNode::willAddSibling(LayoutCursor * cursor, LayoutNode * sibling if (m_color == Color::Grey) { /* The parent is a MatrixLayout, and the current empty row or column is * being filled in, so add a new empty row or column. */ + LayoutRef rootRef = LayoutRef(root()); LayoutNode * parentNode = parent(); assert(parentNode != nullptr); - LayoutRef parentRef(parentNode); - parentNode->willAddSiblingToEmptyChildAtIndex(parentRef.indexOfChild(thisRef)); + parentNode->willAddSiblingToEmptyChildAtIndex(parentNode->indexOfChild(this)); // WARNING: Do not use previous node pointers afterwards. - bool shouldContinueAddition = !(parentRef.isAllocationFailure()); - if (!shouldContinueAddition) { + if (rootRef.isAllocationFailure()) { if (moveCursor) { - cursor->setLayoutReference(parentRef); + cursor->setLayoutReference(rootRef); } return false; } - } if (siblingRef.mustHaveLeftSibling()) { thisRef.setColor(Color::Yellow);