[Tizen] Make assertion when SetParent is not called on the main thread 76/286076/1 accepted/tizen/7.0/unified/20221228.170438
authorHeeyong Song <heeyong.song@samsung.com>
Tue, 27 Dec 2022 07:06:52 +0000 (16:06 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Tue, 27 Dec 2022 08:18:08 +0000 (17:18 +0900)
Change-Id: I31735e43f33995b0d3e39fb489a5f4e77abf0899

dali/internal/event/actors/actor-impl.cpp
dali/internal/event/common/event-thread-services.cpp
dali/internal/event/common/event-thread-services.h
dali/internal/event/common/thread-local-storage.cpp
dali/internal/event/common/thread-local-storage.h

index bf91a94..fa30547 100644 (file)
@@ -1481,7 +1481,7 @@ void Actor::SetParent(ActorParent* parent, bool notify)
     Actor* parentActor = static_cast<Actor*>(parent);
     mScene             = parentActor->mScene;
 
-    if(EventThreadServices::IsCoreRunning() && // Don't emit signals or send messages during Core destruction
+    if(!EventThreadServices::IsShuttingDown() && // Don't emit signals or send messages during Core destruction
        parentActor->OnScene())
     {
       // Instruct each actor to create a corresponding node in the scene graph
@@ -1497,7 +1497,7 @@ void Actor::SetParent(ActorParent* parent, bool notify)
 
     mParent = nullptr;
 
-    if(EventThreadServices::IsCoreRunning() && // Don't emit signals or send messages during Core destruction
+    if(!EventThreadServices::IsShuttingDown() && // Don't emit signals or send messages during Core destruction
        OnScene())
     {
       // Disconnect the Node & its children from the scene-graph.
index 75b6c8a..4bcbda5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,5 +34,10 @@ bool EventThreadServices::IsCoreRunning()
   return ThreadLocalStorage::Created();
 }
 
+bool EventThreadServices::IsShuttingDown()
+{
+  return ThreadLocalStorage::IsSuttingDown();
+}
+
 } // namespace Internal
 } // namespace Dali
index 494a722..99f8bc5 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_EVENT_THREAD_SERVICES_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -118,6 +118,13 @@ public:
    * @return true if core is still running and we can send messages
    */
   static bool IsCoreRunning();
+
+  /**
+   * @brief Check if the event thread service is shutting down.
+   *
+   * @return true if the event thread service is shutting down.
+   */
+  static bool IsShuttingDown();
 };
 
 } // namespace Internal
index 6ebfc68..25b3d06 100644 (file)
@@ -51,8 +51,9 @@ namespace Internal
 {
 namespace
 {
-thread_local ThreadLocalStorage* threadLocal = nullptr;
-}
+thread_local ThreadLocalStorage* threadLocal    = nullptr;
+thread_local bool                isShuttingDown = false;
+} // namespace
 
 ThreadLocalStorage::ThreadLocalStorage(Core* core)
 : mCore(core)
@@ -66,7 +67,8 @@ ThreadLocalStorage::~ThreadLocalStorage() = default;
 
 void ThreadLocalStorage::Remove()
 {
-  threadLocal = nullptr;
+  threadLocal    = nullptr;
+  isShuttingDown = true;
 }
 
 ThreadLocalStorage& ThreadLocalStorage::Get()
@@ -92,6 +94,11 @@ bool ThreadLocalStorage::Created()
   return (threadLocal != nullptr);
 }
 
+bool ThreadLocalStorage::IsSuttingDown()
+{
+  return isShuttingDown;
+}
+
 ThreadLocalStorage* ThreadLocalStorage::GetInternal()
 {
   return threadLocal;
index 16f3876..3f56fdf 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_THREAD_LOCAL_STORAGE_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -90,6 +90,12 @@ public:
   static bool Created();
 
   /**
+   * Checks if the system is shutting down
+   * @return true if the system is shutting down
+   */
+  static bool IsSuttingDown();
+
+  /**
    * Get a pointer to the TLS or NULL if not initialized
    * @return pointer to the TLS
    */