!46936 【mem_leak】修复注册在DisplayMananger中的回调未释放的问题

Merge pull request !46936 from 冯纪拓/leak
This commit is contained in:
openharmony_ci 2024-10-28 13:09:40 +00:00 committed by Gitee
commit b06989dbb1
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 19 additions and 0 deletions

View File

@ -2169,6 +2169,24 @@ void UIContentImpl::Destroy()
Platform::AceContainer::DestroyContainer(instanceId_);
}
ContainerScope::RemoveAndCheck(instanceId_);
UnregisterDisplayManagerCallback();
}
void UIContentImpl::UnregisterDisplayManagerCallback()
{
auto& manager = Rosen::DisplayManager::GetInstance();
if (foldStatusListener_) {
manager.UnregisterFoldStatusListener(foldStatusListener_);
foldStatusListener_ = nullptr;
}
if (foldDisplayModeListener_) {
manager.UnregisterDisplayModeListener(foldDisplayModeListener_);
foldDisplayModeListener_ = nullptr;
}
if (availableAreaChangedListener_) {
manager.UnregisterAvailableAreaListener(availableAreaChangedListener_);
availableAreaChangedListener_ = nullptr;
}
}
void UIContentImpl::OnNewWant(const OHOS::AAFwk::Want& want)

View File

@ -381,6 +381,7 @@ private:
void AddWatchSystemParameter();
void StoreConfiguration(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config);
void UnregisterDisplayManagerCallback();
std::weak_ptr<OHOS::AbilityRuntime::Context> context_;
void* runtime_ = nullptr;