mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[escher] LayoutField: the insertion cursor can't point to an EmptyLayout
as it might be destroyed This fixes the following crash: input 1, OK, input ans/[], go up to the history --> crash
This commit is contained in:
@@ -87,11 +87,7 @@ private:
|
||||
bool selectionIsEmpty() const;
|
||||
void deleteSelection();
|
||||
void invalidateInsertionCursor() { m_insertionCursor = Poincare::LayoutCursor(); }
|
||||
void updateInsertionCursor() {
|
||||
if (!m_insertionCursor.isDefined()) {
|
||||
m_insertionCursor = m_cursor;
|
||||
}
|
||||
}
|
||||
void updateInsertionCursor();
|
||||
|
||||
private:
|
||||
int numberOfSubviews() const override { return 2; }
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <escher/clipboard.h>
|
||||
#include <escher/text_field.h>
|
||||
#include <poincare/expression.h>
|
||||
#include <poincare/empty_layout.h>
|
||||
#include <poincare/horizontal_layout.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
@@ -234,6 +235,17 @@ void LayoutField::ContentView::deleteSelection() {
|
||||
resetSelection();
|
||||
}
|
||||
|
||||
void LayoutField::ContentView::updateInsertionCursor() {
|
||||
if (!m_insertionCursor.isDefined()) {
|
||||
Layout l = m_cursor.layout();
|
||||
if (l.type() == LayoutNode::Type::EmptyLayout && static_cast<EmptyLayout &>(l).color() == EmptyLayoutNode::Color::Grey) {
|
||||
// Don't set m_insertionCursor pointing to a layout which might disappear
|
||||
return;
|
||||
}
|
||||
m_insertionCursor = m_cursor;
|
||||
}
|
||||
}
|
||||
|
||||
View * LayoutField::ContentView::subviewAtIndex(int index) {
|
||||
assert(0 <= index && index < numberOfSubviews());
|
||||
View * m_views[] = {&m_expressionView, &m_cursorView};
|
||||
|
||||
Reference in New Issue
Block a user