Fix text visual discard issue
authorBowon Ryu <bowon.ryu@samsung.com>
Fri, 26 Jul 2024 04:01:00 +0000 (13:01 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Fri, 26 Jul 2024 04:06:50 +0000 (13:06 +0900)
The text visual will be destroyed at next idle time.
Set AsyncTextInterface to nullptr immediately..
This prevents access to the async text interface until the visual is actually destroyed.

Change-Id: Idc1671b2a2f6a3f322fd58cfb1b09489486e5b4c
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/visuals/text/text-visual.cpp

index 2d25b26..d5af313 100644 (file)
@@ -247,6 +247,8 @@ void DiscardTextLabelVisual(Dali::Toolkit::Visual::Base& visual)
 {
   if(DALI_LIKELY(Dali::Stage::IsInstalled() && visual))
   {
+    // This prevents access to the async text interface until the visual is actually destroyed.
+    TextVisual::SetAsyncTextInterface(visual, nullptr);
     Dali::Toolkit::VisualFactory::Get().DiscardVisual(visual);
   }
   visual.Reset();
index b9c166e..8ca9e54 100644 (file)
@@ -757,14 +757,6 @@ void TextVisual::LoadComplete(bool loadingSuccess, TextInformation textInformati
   {
     resourceStatus = Toolkit::Visual::ResourceStatus::READY;
 
-    Actor control = mControl.GetHandle();
-    if(!control)
-    {
-      // Nothing to do.
-      ResourceReady(Toolkit::Visual::ResourceStatus::READY);
-      return;
-    }
-
     Text::AsyncTextRenderInfo renderInfo = textInformation.renderInfo;
 
     if(parameters.requestType == Text::Async::COMPUTE_NATURAL_SIZE || parameters.requestType == Text::Async::COMPUTE_HEIGHT_FOR_WIDTH)
@@ -776,6 +768,14 @@ void TextVisual::LoadComplete(bool loadingSuccess, TextInformation textInformati
       }
     }
 
+    Actor control = mControl.GetHandle();
+    if(!control)
+    {
+      // Nothing to do.
+      ResourceReady(Toolkit::Visual::ResourceStatus::READY);
+      return;
+    }
+
     // Calculate the size of the visual that can fit the text.
     // The size of the text after it has been laid-out, size of pixel data buffer.
     Size layoutSize(static_cast<float>(renderInfo.width), static_cast<float>(renderInfo.height));