From fb0480ba332b58102cae44cc8c612e77a1629bad Mon Sep 17 00:00:00 2001 From: ZhangYu Date: Wed, 24 Jan 2024 08:47:56 +0000 Subject: [PATCH] fix the bug of UIExtension configuration updates Signed-off-by: ZhangYu Change-Id: I4b59ed2fe65074006524e41f8c3ad83828ab33c4 --- wm/include/window_extension_session_impl.h | 2 +- wm/src/window_extension_session_impl.cpp | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/wm/include/window_extension_session_impl.h b/wm/include/window_extension_session_impl.h index efdf609fd6..5493159ca2 100644 --- a/wm/include/window_extension_session_impl.h +++ b/wm/include/window_extension_session_impl.h @@ -83,7 +83,7 @@ protected: private: sptr occupiedAreaChangeListener_; std::optional> focusState_ = std::nullopt; - static std::map>> windowExtensionSessionMap_; + static std::set> windowExtensionSessionSet_; static std::shared_mutex windowExtensionSessionMutex_; }; } // namespace Rosen diff --git a/wm/src/window_extension_session_impl.cpp b/wm/src/window_extension_session_impl.cpp index 3d2f4256d4..64872219f2 100644 --- a/wm/src/window_extension_session_impl.cpp +++ b/wm/src/window_extension_session_impl.cpp @@ -26,7 +26,7 @@ namespace { constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowExtensionSessionImpl"}; } -std::map>> WindowExtensionSessionImpl::windowExtensionSessionMap_; +std::set> WindowExtensionSessionImpl::windowExtensionSessionSet_; std::shared_mutex WindowExtensionSessionImpl::windowExtensionSessionMutex_; WindowExtensionSessionImpl::WindowExtensionSessionImpl(const sptr& option) : WindowSessionImpl(option) @@ -52,8 +52,7 @@ WMError WindowExtensionSessionImpl::Create(const std::shared_ptr lock(windowExtensionSessionMutex_); - windowExtensionSessionMap_.insert(std::make_pair(property_->GetWindowName(), - std::pair>(property_->GetPersistentId(), this))); + windowExtensionSessionSet_.insert(this); } state_ = WindowState::STATE_CREATED; return WMError::WM_OK; @@ -71,8 +70,7 @@ void WindowExtensionSessionImpl::UpdateConfigurationForAll(const std::shared_ptr { WLOGD("notify scene ace update config"); std::unique_lock lock(windowExtensionSessionMutex_); - for (const auto& winPair : windowExtensionSessionMap_) { - auto window = winPair.second.second; + for (const auto& window : windowExtensionSessionSet_) { window->UpdateConfiguration(configuration); } } @@ -97,7 +95,7 @@ WMError WindowExtensionSessionImpl::Destroy(bool needNotifyServer, bool needClea hostSession_ = nullptr; { std::unique_lock lock(windowExtensionSessionMutex_); - windowExtensionSessionMap_.erase(property_->GetWindowName()); + windowExtensionSessionSet_.erase(this); } DelayedSingleton::GetInstance()->OnWindowDestroyed(GetPersistentId()); NotifyAfterDestroy(); -- Gitee