【mem_leak】修复DM中注册回调未释放的问题

Signed-off-by: fengjituo111 <fengjituo@huawei.com>
This commit is contained in:
fengjituo111 2024-10-28 11:48:28 +08:00 committed by 冯纪拓
parent 72b379b75d
commit 557d73ebcd
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;