Fix for application crashing 66/19966/1
authorRichard Underhill <r.underhill@partner.samsung.com>
Thu, 17 Apr 2014 10:22:11 +0000 (11:22 +0100)
committerAndrew Cox <andrew.cox@partner.samsung.com>
Wed, 23 Apr 2014 19:09:38 +0000 (20:09 +0100)
[Problem] Markup was needed to correctly parse each character for
text splitting operations

[Cause] Code assumes a text style per character. Clean solution will
require more work

[Solution] MarkupProcessing is enabled by default on TextInput.
TextView created by TextInput markup is inherited.
Scan for markup is no longer called and is forced by
MarkupProcessingEnabled flag.

Change-Id: I7e4a82271aa8a7eacdfe7aa6e56a12703d467f8b
Signed-off-by: Richard Underhill <r.underhill@partner.samsung.com>
dali-toolkit/internal/controls/text-input/text-input-impl.cpp
dali-toolkit/public-api/markup-processor/markup-processor.cpp

index 69daef1..88bd454 100644 (file)
@@ -327,7 +327,7 @@ TextInput::TextInput()
  mUnderlinedPriorToPreEdit ( false ),
  mCommitByKeyInput( false ),
  mPlaceHolderSet( false ),
  mUnderlinedPriorToPreEdit ( false ),
  mCommitByKeyInput( false ),
  mPlaceHolderSet( false ),
- mMarkUpEnabled( false )
+ mMarkUpEnabled( true )
 {
   // Updates the line height accordingly with the input style.
   UpdateLineHeight();
 {
   // Updates the line height accordingly with the input style.
   UpdateLineHeight();
@@ -846,7 +846,6 @@ TextStyle TextInput::GetStyleAtCursor() const
   if ( !mStyledText.empty() && ( mCursorPosition > 0 ) )
   {
     DALI_ASSERT_DEBUG( ( 0 <= mCursorPosition-1 ) && ( mCursorPosition-1 < mStyledText.size() ) );
   if ( !mStyledText.empty() && ( mCursorPosition > 0 ) )
   {
     DALI_ASSERT_DEBUG( ( 0 <= mCursorPosition-1 ) && ( mCursorPosition-1 < mStyledText.size() ) );
-
     style = mStyledText.at( mCursorPosition-1 ).mStyle;
   }
   else // No text.
     style = mStyledText.at( mCursorPosition-1 ).mStyle;
   }
   else // No text.
@@ -2029,6 +2028,7 @@ void TextInput::SetUpTouchEvents()
 void TextInput::CreateTextViewActor()
 {
   mDisplayedTextView = Toolkit::TextView::New();
 void TextInput::CreateTextViewActor()
 {
   mDisplayedTextView = Toolkit::TextView::New();
+  mDisplayedTextView.SetMarkupProcessingEnabled( mMarkUpEnabled );
   mDisplayedTextView.SetParentOrigin(ParentOrigin::TOP_LEFT);
   mDisplayedTextView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
   mDisplayedTextView.SetMultilinePolicy(Toolkit::TextView::SplitByWord);
   mDisplayedTextView.SetParentOrigin(ParentOrigin::TOP_LEFT);
   mDisplayedTextView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
   mDisplayedTextView.SetMultilinePolicy(Toolkit::TextView::SplitByWord);
index ed4cc57..995253a 100644 (file)
@@ -542,47 +542,11 @@ bool IsTag( std::string::const_iterator& it, const std::string::const_iterator&
 
 } // namespace
 
 
 } // namespace
 
-static inline bool HasMarkup( const std::string& markupString )
-{
-  // Reset counters
-  unsigned int lessThanCount = 0;
-  unsigned int greaterThanCount = 0;
-
-  // Check to see if any markup command surrounds are of equal number and not zero
-  for ( std::string::const_iterator it = markupString.begin(); it != markupString.end(); ++it )
-  {
-    if ( *it == LESS_THAN )
-    {
-      lessThanCount++;
-    }
-    else
-    {
-      if ( *it == GREATER_THAN )
-      {
-        greaterThanCount++;
-      }
-      else
-      {
-        if ( *it == BACK_SLASH )
-        {
-          return true;
-        }
-      }
-    }
-  }
-  if ( !lessThanCount || !greaterThanCount || lessThanCount != greaterThanCount )
-  {
-    return false;
-  }
-  return true;
-}
-
 void GetStyledTextArray( const std::string& markupString, StyledTextArray& styledTextArray, bool scanForMarkup )
 {
   styledTextArray.clear();
 
 void GetStyledTextArray( const std::string& markupString, StyledTextArray& styledTextArray, bool scanForMarkup )
 {
   styledTextArray.clear();
 
-  // Scan markup ( if necessary ) to see if the string contains any change in style from default?
-  if ( !scanForMarkup || !HasMarkup( markupString ) )
+  if ( !scanForMarkup )
   {
     styledTextArray.push_back( StyledText( Text( markupString ), TextStyle() ) );
     return;
   {
     styledTextArray.push_back( StyledText( Text( markupString ), TextStyle() ) );
     return;