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

Merge pull request !47544 from 冯纪拓/cherry-pick-1730690173
This commit is contained in:
openharmony_ci 2024-11-05 12:05:04 +00:00 committed by Gitee
commit 1958dc9e9b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 19 additions and 0 deletions

View File

@ -2117,6 +2117,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

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