From 19b72798b51883512932fbd1e84f35409b473277 Mon Sep 17 00:00:00 2001 From: Shrouq Sabah Date: Thu, 14 Oct 2021 11:29:41 +0300 Subject: [PATCH] Fixed the crash appears after closing app when use ResizePolicy::USE_NATURAL_SIZE 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 --- .../event/size-negotiation/relayout-controller-impl.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dali/internal/event/size-negotiation/relayout-controller-impl.cpp b/dali/internal/event/size-negotiation/relayout-controller-impl.cpp index 622db16..fbf0411 100644 --- a/dali/internal/event/size-negotiation/relayout-controller-impl.cpp +++ b/dali/internal/event/size-negotiation/relayout-controller-impl.cpp @@ -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) -- 2.7.4