From e2bd7ddbe0cb9121fd9cebdfcdfab10811a2395c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Thu, 11 Jan 2018 14:27:20 +0100 Subject: [PATCH] [poincare] Fixed deletion bug in MatrixLayout. Change-Id: I0dbc142468320fac4ed8969a3ef2684549315780 --- poincare/src/layout/matrix_layout.cpp | 6 ++++++ poincare/src/layout/matrix_layout.h | 1 + 2 files changed, 7 insertions(+) diff --git a/poincare/src/layout/matrix_layout.cpp b/poincare/src/layout/matrix_layout.cpp index afccc9260..7626efa06 100644 --- a/poincare/src/layout/matrix_layout.cpp +++ b/poincare/src/layout/matrix_layout.cpp @@ -117,6 +117,12 @@ void MatrixLayout::replaceChildAndMoveCursor(const ExpressionLayout * oldChild, cursor->setPosition(ExpressionLayoutCursor::Position::Left); } +void MatrixLayout::removePointedChildAtIndexAndMoveCursor(int index, bool deleteAfterRemoval, ExpressionLayoutCursor * cursor) { + assert(index >= 0 && index < numberOfChildren()); + assert(cursor->pointedExpressionLayout() == child(index)); + replaceChildAndMoveCursor(child(index), new EmptyVisibleLayout(), deleteAfterRemoval, cursor); +} + int MatrixLayout::writeTextInBuffer(char * buffer, int bufferSize) const { // The grid is a matrix. if (bufferSize == 0) { diff --git a/poincare/src/layout/matrix_layout.h b/poincare/src/layout/matrix_layout.h index 6a58bb0cd..30dccb142 100644 --- a/poincare/src/layout/matrix_layout.h +++ b/poincare/src/layout/matrix_layout.h @@ -19,6 +19,7 @@ public: /* Dynamic layout */ void replaceChild(const ExpressionLayout * oldChild, ExpressionLayout * newChild, bool deleteOldChild = true) override; void replaceChildAndMoveCursor(const ExpressionLayout * oldChild, ExpressionLayout * newChild, bool deleteOldChild, ExpressionLayoutCursor * cursor) override; + void removePointedChildAtIndexAndMoveCursor(int index, bool deleteAfterRemoval, ExpressionLayoutCursor * cursor) override; /* Expression engine */ int writeTextInBuffer(char * buffer, int bufferSize) const override;