mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[escher/expression_field] Fixed dumpLayout
Closing the Calculation app because of a full pool would crash the device, by attempting to dump a layout with no node. Change-Id: Ic926da61ae93f47eb576848788e1de5e3f94f5bb
This commit is contained in:
committed by
Émilie Feral
parent
433639c471
commit
e49dc08759
@@ -26,6 +26,7 @@ public:
|
||||
KDSize minimalSizeForOptimalDisplay() const override;
|
||||
KDPoint drawingOrigin() const;
|
||||
KDPoint absoluteDrawingOrigin() const;
|
||||
bool layoutHasNode() const { return Poincare::TreeNode::IsValidIdentifier(m_layout.identifier()) && !m_layout.wasErasedByException(); }
|
||||
protected:
|
||||
/* Warning: we do not need to delete the previous expression layout when
|
||||
* deleting object or setting a new expression layout. Indeed, the expression
|
||||
|
||||
@@ -32,6 +32,7 @@ public:
|
||||
}
|
||||
bool hasText() const { return layout().hasText(); }
|
||||
Poincare::Layout layout() const { return m_contentView.expressionView()->layout(); }
|
||||
bool layoutHasNode() const { return m_contentView.expressionView()->layoutHasNode(); }
|
||||
CodePoint XNTCodePoint(CodePoint defaultXNTCodePoint) override;
|
||||
void putCursorRightOfLayout();
|
||||
void setInsertionCursorEvent(Ion::Events::Event event) { m_insertionCursorEvent = event; }
|
||||
|
||||
@@ -136,6 +136,16 @@ size_t ExpressionField::dumpLayout(char * buffer, size_t bufferSize) const {
|
||||
* has changed and invalidate the data.*/
|
||||
returnValue = 0;
|
||||
} else {
|
||||
/* dumpLayout will be called whenever Calculation exits, event when an
|
||||
* exception occurs. We thus need to check the validity of the layout we
|
||||
* are dumping (m_layoutField.m_contentView.m_expressionView.m_layout).
|
||||
* However, attempting to get a handle on a layout that has been erased
|
||||
* will crash the program. We need the check to be performed on the
|
||||
* original object in expressionView. */
|
||||
if (!m_layoutField.layoutHasNode()) {
|
||||
buffer[0] = 0;
|
||||
return 0;
|
||||
}
|
||||
size = m_layoutField.layout().size();
|
||||
currentLayout = reinterpret_cast<char *>(m_layoutField.layout().node());
|
||||
returnValue = size;
|
||||
|
||||
Reference in New Issue
Block a user