From 75e34847fe2e6dfd68d8f56159607dbdeba3f096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Tue, 31 Jul 2018 16:23:20 +0200 Subject: [PATCH] [poincare] Wrong memoization of index in parent --- poincare/src/vertical_offset_layout_node.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/poincare/src/vertical_offset_layout_node.cpp b/poincare/src/vertical_offset_layout_node.cpp index 47040f812..676521b3e 100644 --- a/poincare/src/vertical_offset_layout_node.cpp +++ b/poincare/src/vertical_offset_layout_node.cpp @@ -242,21 +242,21 @@ bool VerticalOffsetLayoutNode::willAddSibling(LayoutCursor * cursor, LayoutNode VerticalOffsetLayoutNode * verticalOffsetSibling = static_cast(sibling); if (verticalOffsetSibling->type() == Type::Superscript) { LayoutRef rootLayout = root(); - LayoutNode * parentNode = parent(); - LayoutRef parentRef = LayoutRef(parentNode); - assert(parentNode->isHorizontal()); + LayoutRef thisRef = LayoutRef(this); + LayoutRef parentRef = LayoutRef(parent()); + assert(parentRef.isHorizontal()); // Add the Left parenthesis - int idxInParent = parentNode->indexOfChild(this); + int idxInParent = parentRef.indexOfChild(thisRef); int leftParenthesisIndex = idxInParent; LeftParenthesisLayoutRef leftParenthesis = LeftParenthesisLayoutRef(); int numberOfOpenParenthesis = 0; while (leftParenthesisIndex > 0 - && parentNode->childAtIndex(leftParenthesisIndex-1)->isCollapsable(&numberOfOpenParenthesis, true)) + && parentRef.childAtIndex(leftParenthesisIndex-1).isCollapsable(&numberOfOpenParenthesis, true)) { leftParenthesisIndex--; } parentRef.addChildAtIndex(leftParenthesis, leftParenthesisIndex, parentRef.numberOfChildren(), nullptr); - idxInParent++; + idxInParent = parentRef.indexOfChild(thisRef); // Add the Right parenthesis RightParenthesisLayoutRef rightParenthesis = RightParenthesisLayoutRef();