Add DestroyInfo to ClearCharacterModelData 46/319746/1
authorBowon Ryu <bowon.ryu@samsung.com>
Mon, 17 Feb 2025 07:57:48 +0000 (16:57 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Mon, 17 Feb 2025 07:57:48 +0000 (16:57 +0900)
When the text model is partially cleared through ClearCharacterModelData,
BidirectionalInfo should also be destroyed.

Change-Id: I6557add9ab63c11d6f5ad4e671d3ab88ef2a0ca3
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
dali-toolkit/internal/text/controller/text-controller-impl-data-clearer.cpp

index 4165425e3425227c71646bfa95cc0d3a4b5b6725..6bc21a671b6023baacfe1fd4a873e5ec08aa6c4b 100644 (file)
@@ -136,10 +136,31 @@ void ControllerImplDataClearer::ClearCharacterModelData(Controller::Impl& impl,
   {
     if(Controller::NO_OPERATION != (Controller::BIDI_INFO & operations))
     {
+      uint32_t startRemoveIndex = model->mLogicalModel->mBidirectionalParagraphInfo.Count();
+      uint32_t endRemoveIndex   = startRemoveIndex;
+
       // Clear the bidirectional paragraph info.
       ClearCharacterRuns(startIndex,
                          endIndex,
-                         model->mLogicalModel->mBidirectionalParagraphInfo);
+                         model->mLogicalModel->mBidirectionalParagraphInfo,
+                         startRemoveIndex,
+                         endRemoveIndex);
+
+      BidirectionalParagraphInfoRun* bidirectionalInfoBuffer = model->mLogicalModel->mBidirectionalParagraphInfo.Begin();
+      // Free the allocated memory used to store the bidirectional info.
+      for(Vector<BidirectionalParagraphInfoRun>::Iterator it    = bidirectionalInfoBuffer + startRemoveIndex,
+                                                          endIt = bidirectionalInfoBuffer + endRemoveIndex;
+          it != endIt;
+          ++it)
+      {
+        BidirectionalParagraphInfoRun& bidiInfo = *it;
+
+        TextAbstraction::BidirectionalSupport bidirectionalSupport = TextAbstraction::BidirectionalSupport::Get();
+        bidirectionalSupport.DestroyInfo(bidiInfo.bidirectionalInfoIndex);
+      }
+
+      model->mLogicalModel->mBidirectionalParagraphInfo.Erase(bidirectionalInfoBuffer + startRemoveIndex,
+                                                              bidirectionalInfoBuffer + endRemoveIndex);
 
       // Clear the character's directions.
       CharacterDirection* characterDirectionsBuffer = model->mLogicalModel->mCharacterDirections.Begin();