From 9bc5785292d33ea6a665eed6395386e9e1c62c80 Mon Sep 17 00:00:00 2001 From: Seoyeon Kim Date: Mon, 4 Dec 2017 14:59:08 +0900 Subject: [PATCH] Add the protected code and fix the crash issue - When visualModel->mLines.Begin() is NULL, then do nothing in GetCursorPosition(). - When the user tries to input some texts in TextField, and its size is fitted to its parent, which size is (0,0) by Relayout, then set mTextUpdateInfo.mNumberOfCharactersToAdd as the current text for UpdateModel(). Change-Id: Iea0a251ba2061389bf7a00476bf126d9669da50c Signed-off-by: Seoyeon Kim --- dali-toolkit/internal/text/cursor-helper-functions.cpp | 10 +++++++--- dali-toolkit/internal/text/text-controller.cpp | 7 +++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/dali-toolkit/internal/text/cursor-helper-functions.cpp b/dali-toolkit/internal/text/cursor-helper-functions.cpp index 91b6a40..f437b8d 100644 --- a/dali-toolkit/internal/text/cursor-helper-functions.cpp +++ b/dali-toolkit/internal/text/cursor-helper-functions.cpp @@ -467,6 +467,13 @@ CharacterIndex GetClosestCursorIndex( VisualModelPtr visualModel, void GetCursorPosition( GetCursorPositionParameters& parameters, CursorInfo& cursorInfo ) { + const LineRun* const modelLines = parameters.visualModel->mLines.Begin(); + if( NULL == modelLines ) + { + // Nothing to do. + return; + } + // Whether the logical cursor position is at the end of the whole text. const bool isLastPosition = parameters.logicalModel->mText.Count() == parameters.logical; @@ -476,8 +483,6 @@ void GetCursorPosition( GetCursorPositionParameters& parameters, // Whether the cursor is in the last position and the last position is a new paragraph character. const bool isLastNewParagraph = parameters.isMultiline && isLastPosition && TextAbstraction::IsNewParagraph( *( parameters.logicalModel->mText.Begin() + characterOfLine ) ); - const LineRun* const modelLines = parameters.visualModel->mLines.Begin(); - const LineIndex lineIndex = parameters.visualModel->GetLineOfCharacter( characterOfLine ); const LineRun& line = *( modelLines + lineIndex ); @@ -665,7 +670,6 @@ void GetCursorPosition( GetCursorPositionParameters& parameters, // Set the primary cursor's height. cursorInfo.primaryCursorHeight = cursorInfo.isSecondaryCursor ? 0.5f * glyphMetrics.fontHeight : glyphMetrics.fontHeight; - cursorInfo.glyphOffset = line.ascender - glyphMetrics.ascender; // Set the primary cursor's position. cursorInfo.primaryPosition.x = -glyphMetrics.xBearing + primaryPosition.x + glyphAdvance; diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 1c15e22..15e7b8b 100755 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -2146,6 +2146,13 @@ Controller::UpdateTextType Controller::Relayout( const Size& size ) { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "new size (previous size %f,%f)\n", mImpl->mModel->mVisualModel->mControlSize.width, mImpl->mModel->mVisualModel->mControlSize.height ); + if( ( 0 == mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd ) && + ( 0 == mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters ) && + ( ( mImpl->mModel->mVisualModel->mControlSize.width < Math::MACHINE_EPSILON_1000 ) || ( mImpl->mModel->mVisualModel->mControlSize.height < Math::MACHINE_EPSILON_1000 ) ) ) + { + mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = mImpl->mModel->mLogicalModel->mText.Count(); + } + // Layout operations that need to be done if the size changes. mImpl->mOperationsPending = static_cast( mImpl->mOperationsPending | LAYOUT | -- 2.7.4