Merge "Add the protected code and fix the crash issue" into devel/master
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 22 Dec 2017 15:07:43 +0000 (15:07 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Fri, 22 Dec 2017 15:07:43 +0000 (15:07 +0000)
dali-toolkit/internal/text/cursor-helper-functions.cpp
dali-toolkit/internal/text/text-controller.cpp

index 91b6a40..f437b8d 100644 (file)
@@ -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;
index 6509467..d454031 100755 (executable)
@@ -2178,6 +2178,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<OperationsMask>( mImpl->mOperationsPending |
                                                              LAYOUT                    |