diff --git a/escher/src/text_field.cpp b/escher/src/text_field.cpp index 649e803a7..122727cee 100644 --- a/escher/src/text_field.cpp +++ b/escher/src/text_field.cpp @@ -149,12 +149,11 @@ bool TextField::ContentView::removePreviousGlyph() { if (m_horizontalAlignment > 0.0f) { /* Reload the view. If we do it later, the text beins supposedly shorter, we - * will not clean the first char. */ + * will not clean the first char. */ reloadRectFromPosition(m_draftTextBuffer); } // Remove the glyph if possible - CodePoint removedCodePoint = 0; - int removedSize = UTF8Helper::RemovePreviousGlyph(m_draftTextBuffer, const_cast(cursorLocation()), &removedCodePoint); + int removedSize = UTF8Helper::RemovePreviousGlyph(m_draftTextBuffer, const_cast(cursorLocation())); if (removedSize == 0) { assert(cursorLocation() == m_draftTextBuffer); return false; diff --git a/ion/include/ion/unicode/utf8_helper.h b/ion/include/ion/unicode/utf8_helper.h index fb4938b11..94994b086 100644 --- a/ion/include/ion/unicode/utf8_helper.h +++ b/ion/include/ion/unicode/utf8_helper.h @@ -72,7 +72,7 @@ bool CodePointIsUpperCaseLetter(CodePoint c); bool CodePointIsNumber(CodePoint c); // Shift the buffer and return the number of bytes removed. -int RemovePreviousGlyph(const char * text, char * location, CodePoint * c); +int RemovePreviousGlyph(const char * text, char * location, CodePoint * c = nullptr); /* Return the pointer to the (non combining) code point whose glyph is displayed * at the given position, and vice-versa */ diff --git a/ion/src/shared/unicode/utf8_helper.cpp b/ion/src/shared/unicode/utf8_helper.cpp index 944163d81..d0ed6f001 100644 --- a/ion/src/shared/unicode/utf8_helper.cpp +++ b/ion/src/shared/unicode/utf8_helper.cpp @@ -267,7 +267,6 @@ bool CodePointIsNumber(CodePoint c) { } int RemovePreviousGlyph(const char * text, char * location, CodePoint * c) { - assert(c != nullptr); if (location <= text) { assert(location == text); return 0; @@ -276,7 +275,9 @@ int RemovePreviousGlyph(const char * text, char * location, CodePoint * c) { // Find the previous glyph UTF8Decoder decoder(text, location); const char * previousGlyphPos = decoder.previousGlyphPosition(); - *c = decoder.nextCodePoint(); + if (c != nullptr) { + *c = decoder.nextCodePoint(); + } // Shift the buffer int shiftedSize = location - previousGlyphPos;