From: Heeyong Song Date: Wed, 10 Nov 2021 15:25:21 +0000 (+0900) Subject: Add mutex to the Adaptor X-Git-Tag: dali_2.0.53~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git;a=commitdiff_plain;h=06c03cadaaba54a0247af6df4a0b043e9b561e6f Add mutex to the Adaptor Prevent the main thread and the update thread from accessing the mWindows at the same time Change-Id: I3ab8e9565b37165451468771d89967493a27985b --- diff --git a/dali/internal/adaptor/common/adaptor-impl.cpp b/dali/internal/adaptor/common/adaptor-impl.cpp index feac31b..d880a94 100644 --- a/dali/internal/adaptor/common/adaptor-impl.cpp +++ b/dali/internal/adaptor/common/adaptor-impl.cpp @@ -295,7 +295,6 @@ void Adaptor::Initialize(GraphicsFactory& graphicsFactory) Integration::SetTapMaximumAllowedTime(mEnvironmentOptions->GetTapMaximumAllowedTime()); } - std::string systemCachePath = GetSystemCachePath(); if(!systemCachePath.empty()) { @@ -675,7 +674,10 @@ bool Adaptor::AddWindow(Dali::Integration::SceneHolder childWindow) windowImpl.GetRootLayer().SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, mRootLayoutDirection); // Add the new Window to the container - the order is not important - mWindows.push_back(&windowImpl); + { + Dali::Mutex::ScopedLock lock(mMutex); + mWindows.push_back(&windowImpl); + } Dali::RenderSurfaceInterface* surface = windowImpl.GetSurface(); @@ -693,6 +695,7 @@ bool Adaptor::RemoveWindow(Dali::Integration::SceneHolder* childWindow) { if(*iter == &windowImpl) { + Dali::Mutex::ScopedLock lock(mMutex); mWindows.erase(iter); return true; } @@ -707,6 +710,7 @@ bool Adaptor::RemoveWindow(std::string childWindowName) { if((*iter)->GetName() == childWindowName) { + Dali::Mutex::ScopedLock lock(mMutex); mWindows.erase(iter); return true; } @@ -721,6 +725,7 @@ bool Adaptor::RemoveWindow(Internal::Adaptor::SceneHolder* childWindow) { if((*iter)->GetId() == childWindow->GetId()) { + Dali::Mutex::ScopedLock lock(mMutex); mWindows.erase(iter); return true; } @@ -815,6 +820,7 @@ Integration::PlatformAbstraction& Adaptor::GetPlatformAbstraction() const void Adaptor::GetWindowContainerInterface(WindowContainer& windows) { + Dali::Mutex::ScopedLock lock(mMutex); windows = mWindows; } @@ -1221,6 +1227,7 @@ Adaptor::Adaptor(Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor, mSystemTracer(), mObjectProfiler(nullptr), mSocketFactory(), + mMutex(), mThreadMode(threadMode), mEnvironmentOptionsOwned(environmentOptions ? false : true /* If not provided then we own the object */), mUseRemoteSurface(false), diff --git a/dali/internal/adaptor/common/adaptor-impl.h b/dali/internal/adaptor/common/adaptor-impl.h index 331ab9a..69a6b3f 100644 --- a/dali/internal/adaptor/common/adaptor-impl.h +++ b/dali/internal/adaptor/common/adaptor-impl.h @@ -19,6 +19,7 @@ */ // EXTERNAL INCLUDES +#include #include #include #include @@ -679,6 +680,7 @@ private: // Data SystemTrace mSystemTracer; ///< System tracer ObjectProfiler* mObjectProfiler; ///< Tracks object lifetime for profiling SocketFactory mSocketFactory; ///< Socket factory + Mutex mMutex; ///< Mutex ThreadMode mThreadMode; ///< The thread mode const bool mEnvironmentOptionsOwned : 1; ///< Whether we own the EnvironmentOptions (and thus, need to delete it) bool mUseRemoteSurface : 1; ///< whether the remoteSurface is used or not