router leak bug fix

Signed-off-by: yuzhicheng <yuzhicheng4@huawei.com>
Change-Id: I879519d3aa864da261d2506b2f88af946138ae2c
This commit is contained in:
yuzhicheng 2024-09-23 21:15:47 +08:00
parent 8b80c8f770
commit 7bb13df7e2
3 changed files with 6 additions and 4 deletions

View File

@ -216,7 +216,6 @@ void BuildMenu(const RefPtr<NavBarNode>& navBarNode, const RefPtr<TitleBarNode>&
if (navBarNode->GetMenuNodeOperationValue(ChildNodeOperation::NONE) == ChildNodeOperation::REPLACE) {
titleBarNode->RemoveChild(titleBarNode->GetMenu());
titleBarNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
navBarNode->UpdateMenuNodeOperation(ChildNodeOperation::NONE);
}
if (navBarNode->GetPrevMenuIsCustomValue(false)) {
if (navBarNode->GetMenuNodeOperationValue(ChildNodeOperation::NONE) == ChildNodeOperation::NONE) {

View File

@ -34,7 +34,6 @@ void BuildMenu(const RefPtr<NavDestinationGroupNode>& navDestinationGroupNode, c
if (navDestinationGroupNode->GetMenuNodeOperationValue(ChildNodeOperation::NONE) == ChildNodeOperation::REPLACE) {
titleBarNode->RemoveChild(titleBarNode->GetMenu());
titleBarNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
navDestinationGroupNode->UpdateMenuNodeOperation(ChildNodeOperation::NONE);
}
if (navDestinationGroupNode->GetPrevMenuIsCustomValue(false)) {
if (navDestinationGroupNode->GetMenuNodeOperationValue(ChildNodeOperation::NONE) == ChildNodeOperation::NONE) {
@ -326,7 +325,6 @@ void NavDestinationPattern::OnAttachToFrameNode()
auto pipeline = host->GetContext();
CHECK_NULL_VOID(pipeline);
pipeline->AddWindowStateChangedCallback(id);
pipeline->AddWindowSizeChangeCallback(id);
}
void NavDestinationPattern::OnDetachFromFrameNode(FrameNode* frameNode)
@ -336,7 +334,6 @@ void NavDestinationPattern::OnDetachFromFrameNode(FrameNode* frameNode)
auto pipeline = frameNode->GetContext();
CHECK_NULL_VOID(pipeline);
pipeline->RemoveWindowStateChangedCallback(id);
pipeline->RemoveWindowSizeChangeCallback(id);
}
void NavDestinationPattern::DumpInfo()

View File

@ -76,6 +76,11 @@ void UIObserverListener::OnRouterPageStateChange(const NG::RouterPageInfoNG& pag
"Handle router page state change failed, runtime or callback function invalid!");
return;
}
napi_handle_scope scope = nullptr;
auto status = napi_open_handle_scope(env_, &scope);
if (status != napi_ok) {
return;
}
napi_value callback = nullptr;
napi_get_reference_value(env_, callback_, &callback);
napi_value objValue = nullptr;
@ -99,6 +104,7 @@ void UIObserverListener::OnRouterPageStateChange(const NG::RouterPageInfoNG& pag
napi_set_named_property(env_, objValue, "pageId", napiPageId);
napi_value argv[] = { objValue };
napi_call_function(env_, nullptr, callback, 1, argv, nullptr);
napi_close_handle_scope(env_, scope);
}
void UIObserverListener::OnDensityChange(double density)