From 9a8ea25dabb769b29de1074d85c1ed54fa72ca08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Tue, 31 Jul 2018 18:02:54 +0200 Subject: [PATCH] [poincare] LayoutNode::changeGreySquaresOfAllMatrixAncestors uses Refs --- poincare/include/poincare/layout_reference.h | 1 + poincare/src/layout_node.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/poincare/include/poincare/layout_reference.h b/poincare/include/poincare/layout_reference.h index 978f6d77d..1bc60971d 100644 --- a/poincare/include/poincare/layout_reference.h +++ b/poincare/include/poincare/layout_reference.h @@ -44,6 +44,7 @@ public: bool mustHaveLeftSibling() const { return const_cast(this)->node()->mustHaveLeftSibling(); } bool isEmpty() const { return const_cast(this)->node()->isEmpty(); } bool isHorizontal() const { return const_cast(this)->node()->isHorizontal(); } + bool isMatrix() const { return const_cast(this)->node()->isMatrix(); } bool isVerticalOffset() const { return const_cast(this)->node()->isVerticalOffset(); } bool isLeftParenthesis() const { return const_cast(this)->node()->isLeftParenthesis(); } bool isCollapsable(int * numberOfOpenParenthesis, bool goingLeft) const { return const_cast(this)->node()->isCollapsable(numberOfOpenParenthesis, goingLeft); } diff --git a/poincare/src/layout_node.cpp b/poincare/src/layout_node.cpp index 77398a718..b5f3350e7 100644 --- a/poincare/src/layout_node.cpp +++ b/poincare/src/layout_node.cpp @@ -255,17 +255,17 @@ void LayoutNode::scoreCursorInDescendantsVertically ( bool LayoutNode::changeGreySquaresOfAllMatrixAncestors(bool add) { bool changedSquares = false; - LayoutNode * currentAncestor = parent(); - while (currentAncestor != nullptr) { - if (currentAncestor->isMatrix()) { + LayoutRef currentAncestor = LayoutRef(parent()); + while (currentAncestor.isDefined()) { + if (currentAncestor.isMatrix()) { if (add) { - static_cast(currentAncestor)->addGreySquares(); + static_cast(currentAncestor.node())->addGreySquares(); } else { - static_cast(currentAncestor)->removeGreySquares(); + static_cast(currentAncestor.node())->removeGreySquares(); } changedSquares = true; } - currentAncestor = currentAncestor->parent(); + currentAncestor = currentAncestor.parent(); } return changedSquares; }