Fixed the crash appears after closing app when use ResizePolicy::USE_NATURAL_SIZE 01/265301/3
authorShrouq Sabah <s.sabah@samsung.com>
Thu, 14 Oct 2021 08:29:41 +0000 (11:29 +0300)
committershrouq Sabah <s.sabah@samsung.com>
Tue, 7 Dec 2021 07:31:48 +0000 (07:31 +0000)
There is a crash when destroying text-editor and the ResizePolicy is USE_NATURAL_SIZE.

textEditor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);"
then close the application. the below exception appears.
ERROR: DALI: Assert (threadLocal) failed in: static Dali::Internal::ThreadLocalStorage& Dali::Internal::ThreadLocalStorage::Get()
Exception:
threadLocal
 thrown at static Dali::Internal::ThreadLocalStorage& Dali::Internal::ThreadLocalStorage::Get()
terminate called after throwing an instance of 'Dali::DaliException'

The solution applied at RelayoutController::Get().
Checked if ThreadLocalStorage is created then proceed normally otherwise returns null
Because the ThreadLocalStorage::Get() only retrieves STL without checking if it exists.

The caller of RelayoutController::Get() should check if RelayoutController is not null.
There is only one place use this function and already checks if RelayoutController is not null.

Change-Id: I343ef47f03aa86babb4bdd19f95c3e7ccb211dff

dali/internal/event/size-negotiation/relayout-controller-impl.cpp

index 622db16..fbf0411 100644 (file)
@@ -125,7 +125,15 @@ RelayoutController::~RelayoutController()
 
 RelayoutController* RelayoutController::Get()
 {
-  return &ThreadLocalStorage::Get().GetRelayoutController();
+  // There was crash when destroying actors and the ResizePolicy is USE_NATURAL_SIZE
+  // The ThreadLocalStorage::Get() only retrieve STL without checking if it exists.
+  // The caller of RelayoutController::Get() should check if RelayoutController is not null.
+  if(ThreadLocalStorage::Created())
+  {
+    return &ThreadLocalStorage::Get().GetRelayoutController();
+  }
+
+  return nullptr;
 }
 
 void RelayoutController::QueueActor(Internal::Actor* actor, RelayoutContainer& actors, Vector2 size)