Merge "Make AsyncTask destructor called out of mutex" into devel/master
authorEunki Hong <eunkiki.hong@samsung.com>
Fri, 20 Oct 2023 09:20:04 +0000 (09:20 +0000)
committerGerrit Code Review <gerrit@review>
Fri, 20 Oct 2023 09:20:04 +0000 (09:20 +0000)
dali/integration-api/adaptor-framework/scene-holder-impl.cpp
dali/integration-api/adaptor-framework/scene-holder-impl.h
dali/public-api/dali-adaptor-version.cpp
packaging/dali-adaptor.spec

index e5703e4..6d281f6 100644 (file)
@@ -56,14 +56,24 @@ uint32_t SceneHolder::mSceneHolderCounter = 0;
 class SceneHolder::SceneHolderLifeCycleObserver : public LifeCycleObserver
 {
 public:
-  SceneHolderLifeCycleObserver(Adaptor*& adaptor)
-  : mAdaptor(adaptor){};
+  SceneHolderLifeCycleObserver(Adaptor*& adaptor, bool& adaptorStarted)
+  : mAdaptor(adaptor),
+    mAdaptorStarted(adaptorStarted)
+  {
+  }
 
 private: // Adaptor::LifeCycleObserver interface
-  void OnStart() override{};
+  void OnStart() override
+  {
+    mAdaptorStarted = true;
+  };
   void OnPause() override{};
   void OnResume() override{};
-  void OnStop() override{};
+  void OnStop() override
+  {
+    // Mark adaptor as stopped;
+    mAdaptorStarted = false;
+  };
   void OnDestroy() override
   {
     mAdaptor = nullptr;
@@ -71,17 +81,17 @@ private: // Adaptor::LifeCycleObserver interface
 
 private:
   Adaptor*& mAdaptor;
+  bool&     mAdaptorStarted;
 };
 
 SceneHolder::SceneHolder()
-: mLifeCycleObserver(new SceneHolderLifeCycleObserver(mAdaptor)),
+: mLifeCycleObserver(new SceneHolderLifeCycleObserver(mAdaptor, mAdaptorStarted)),
   mLastTouchEvent(),
   mLastHoverEvent(),
   mId(mSceneHolderCounter++),
   mSurface(nullptr),
   mAdaptor(nullptr),
   mDpi(),
-  mIsBeingDeleted(false),
   mAdaptorStarted(false),
   mVisible(true)
 {
@@ -100,8 +110,12 @@ SceneHolder::~SceneHolder()
     mAdaptor->RemoveObserver(*mLifeCycleObserver.get());
     mAdaptor->RemoveWindow(this);
 
-    // The event queue is flushed and we wait for the completion of the surface removal
-    mAdaptor->DeleteSurface(*mSurface.get());
+    if(mAdaptorStarted)
+    {
+      // The event queue is flushed and we wait for the completion of the surface removal
+      // Note : we don't need to delete surface when adaptor is stopped now.
+      mAdaptor->DeleteSurface(*mSurface.get());
+    }
 
     mAdaptor = nullptr;
   }
@@ -225,6 +239,7 @@ void SceneHolder::SetAdaptor(Dali::Adaptor& adaptor)
 
   DALI_ASSERT_DEBUG(mSurface && "Surface needs to be set before calling this method\n");
 
+  // We can assume that current adaptor is already started now.
   mAdaptorStarted = true;
 
   // Create the scene
@@ -288,6 +303,12 @@ void SceneHolder::SetRotationCompletedAcknowledgement()
 
 void SceneHolder::FeedTouchPoint(Dali::Integration::Point& point, int timeStamp)
 {
+  if(DALI_UNLIKELY(!mAdaptorStarted))
+  {
+    DALI_LOG_ERROR("Adaptor is stopped, or not be started yet. Ignore this feed.\n");
+    return;
+  }
+
   if(timeStamp < 1)
   {
     timeStamp = TimeService::GetMilliSeconds();
@@ -337,6 +358,12 @@ const Dali::HoverEvent& SceneHolder::GetLastHoverEvent() const
 
 void SceneHolder::FeedWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
 {
+  if(DALI_UNLIKELY(!mAdaptorStarted))
+  {
+    DALI_LOG_ERROR("Adaptor is stopped, or not be started yet. Ignore this feed.\n");
+    return;
+  }
+
   // Signals can be emitted while processing core events, and the scene holder could be deleted in the signal callback.
   // Keep the handle alive until the core events are processed.
   Dali::BaseHandle sceneHolder(this);
@@ -350,6 +377,12 @@ void SceneHolder::FeedWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
 
 void SceneHolder::FeedKeyEvent(Dali::Integration::KeyEvent& keyEvent)
 {
+  if(DALI_UNLIKELY(!mAdaptorStarted))
+  {
+    DALI_LOG_ERROR("Adaptor is stopped, or not be started yet. Ignore this feed.\n");
+    return;
+  }
+
   Dali::PhysicalKeyboard physicalKeyboard = PhysicalKeyboard::Get();
   if(physicalKeyboard)
   {
@@ -370,6 +403,12 @@ void SceneHolder::FeedKeyEvent(Dali::Integration::KeyEvent& keyEvent)
 
 void SceneHolder::FeedHoverEvent(Dali::Integration::Point& point)
 {
+  if(DALI_UNLIKELY(!mAdaptorStarted))
+  {
+    DALI_LOG_ERROR("Adaptor is stopped, or not be started yet. Ignore this feed.\n");
+    return;
+  }
+
   Integration::HoverEvent hoverEvent;
 
   // Signals can be emitted while processing core events, and the scene holder could be deleted in the signal callback.
@@ -418,6 +457,8 @@ Dali::Integration::SceneHolder SceneHolder::Get(Dali::Actor actor)
 
 void SceneHolder::Reset()
 {
+  DALI_ASSERT_ALWAYS(mAdaptorStarted && "Adaptor is stopped, or not be started yet!");
+
   mCombiner.Reset();
 
   // Any touch listeners should be told of the interruption.
index c4e8cdd..21c3c02 100644 (file)
@@ -161,16 +161,6 @@ public:
   void Resume();
 
   /**
-   * @brief Checks whether this scene holder is being deleted in the event thread.
-   *
-   * @return true if this scene holder is being deleted in the event thread, or false if not.
-   */
-  bool IsBeingDeleted() const
-  {
-    return mIsBeingDeleted;
-  }
-
-  /**
    * @brief Informs the scene that the set surface has been rotated.
    *
    * @param[in] width The width of rotated surface
@@ -407,10 +397,8 @@ protected:
 
   Uint16Pair mDpi; ///< The DPI for this SceneHolder.
 
-  std::atomic<bool> mIsBeingDeleted; ///< This is set only from the event thread and read only from the render thread
-
-  bool mAdaptorStarted : 1; ///< Whether the adaptor has started or not
-  bool mVisible : 1;        ///< Whether the scene is visible or not
+  bool mAdaptorStarted; ///< Whether the adaptor has started or not
+  bool mVisible : 1;    ///< Whether the scene is visible or not
 };
 
 } // namespace Adaptor
index 5305a74..72d2e99 100644 (file)
@@ -27,7 +27,7 @@ namespace Dali
 {
 const unsigned int ADAPTOR_MAJOR_VERSION = 2;
 const unsigned int ADAPTOR_MINOR_VERSION = 2;
-const unsigned int ADAPTOR_MICRO_VERSION = 48;
+const unsigned int ADAPTOR_MICRO_VERSION = 49;
 const char* const  ADAPTOR_BUILD_DATE    = __DATE__ " " __TIME__;
 
 #ifdef DEBUG_ENABLED
index eab7e4d..7b6ecc4 100644 (file)
@@ -17,7 +17,7 @@
 
 Name:       dali2-adaptor
 Summary:    The DALi Tizen Adaptor
-Version:    2.2.48
+Version:    2.2.49
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0 and BSD-3-Clause and MIT