!48959 修复navigationRoute空指针

Merge pull request !48959 from tsj_2020/request
This commit is contained in:
openharmony_ci 2024-11-22 05:34:23 +00:00 committed by Gitee
commit c22affbba4
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 29 additions and 13 deletions

View File

@ -846,15 +846,31 @@ int32_t JSNavigationStack::LoadDestination(const std::string& name, const JSRef<
}
// deal route config and execute route config builder
auto container = Container::Current();
CHECK_NULL_RETURN(container, ERROR_CODE_INTERNAL_ERROR);
auto navigationRoute = container->GetNavigationRoute();
if (!navigationRoute->HasLoaded(name)) {
int32_t res = navigationRoute->LoadPage(name);
if (res != 0) {
TAG_LOGE(AceLogTag::ACE_NAVIGATION, "load page failed: %{public}s", name.c_str());
return navDestBuilderFunc_->IsEmpty() ? ERROR_CODE_BUILDER_FUNCTION_NOT_REGISTERED
: ERROR_CODE_DESTINATION_NOT_FOUND;
}
if (!navigationRoute) {
TAG_LOGI(AceLogTag::ACE_NAVIGATION, "navigation route is invalid");
return ERROR_CODE_INTERNAL_ERROR;
}
if (!navigationRoute->HasLoaded(name) && navigationRoute->LoadPage(name) != 0) {
TAG_LOGE(AceLogTag::ACE_NAVIGATION, "load page failed: %{public}s", name.c_str());
return navDestBuilderFunc_->IsEmpty() ? ERROR_CODE_BUILDER_FUNCTION_NOT_REGISTERED
: ERROR_CODE_DESTINATION_NOT_FOUND;
}
int32_t result = ExecuteBuilderByConfig(name, customNode, param);
if (result != ERROR_CODE_NO_ERROR) {
return result;
}
node = NG::ViewStackProcessor::GetInstance()->Finish();
if (!GetNavDestinationNodeInUINode(node, desNode)) {
return ERROR_CODE_DESTINATION_NOT_FOUND;
}
return ERROR_CODE_NO_ERROR;
}
int32_t JSNavigationStack::ExecuteBuilderByConfig(const std::string& name,
const WeakPtr<NG::UINode>& customNode, const JSRef<JSVal>& param)
{
auto parentCustomNode = AceType::DynamicCast<NG::CustomNode>(customNode.Upgrade());
CHECK_NULL_RETURN(parentCustomNode, ERROR_CODE_INTERNAL_ERROR);
auto thisObjTmp = parentCustomNode->FireThisFunc();
@ -883,10 +899,6 @@ int32_t JSNavigationStack::LoadDestination(const std::string& name, const JSRef<
}
auto builder = JSRef<JSFunc>::Cast(builderProp);
builder->Call(thisObj, number, params);
node = NG::ViewStackProcessor::GetInstance()->Finish();
if (!GetNavDestinationNodeInUINode(node, desNode)) {
return ERROR_CODE_DESTINATION_NOT_FOUND;
}
return ERROR_CODE_NO_ERROR;
}

View File

@ -152,6 +152,8 @@ private:
bool GetNeedUpdatePathInfo(int32_t index);
void SetNeedUpdatePathInfo(int32_t index, bool need);
int32_t ExecuteBuilderByConfig(const std::string& name,
const WeakPtr<NG::UINode>& customNode, const JSRef<JSVal>& param);
JSRef<JSArray> GetPathArray();
JSRef<JSObject> GetPathInfo(int32_t index);

View File

@ -298,8 +298,10 @@ bool StageManager::PopPage(const RefPtr<FrameNode>& inPage, bool needShowNext, b
}
return true;
}
stageNode_->RemoveChild(pageNode);
pageNode->SetChildrenInDestroying();
if (pageNode) {
stageNode_->RemoveChild(pageNode);
pageNode->SetChildrenInDestroying();
}
stageNode_->RebuildRenderContextTree();
pipeline->RequestFrame();
return true;