!1636 fix onExecutionFailedCallBackInfo bug in taskgroup

Merge pull request !1636 from huangfeijie/fix_group_cancel
This commit is contained in:
openharmony_ci 2024-11-12 15:24:44 +00:00 committed by Gitee
commit 27ecf90cec
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -559,7 +559,10 @@ void TaskPool::UpdateGroupInfoByResult(napi_env env, Task* task, napi_value res,
napi_value res = nullptr;
napi_get_element(env, resArr, groupInfo->GetFailedIndex(), &res);
napi_reject_deferred(env, groupInfo->deferred, res);
if (task->onExecutionFailedCallBackInfo_ != nullptr) {
auto iter = taskGroup->taskIds_.begin();
std::advance(iter, groupInfo->GetFailedIndex());
auto task = iter != taskGroup->taskIds_.end() ? TaskManager::GetInstance().GetTask(*iter) : nullptr;
if (task != nullptr && task->onExecutionFailedCallBackInfo_ != nullptr) {
task->onExecutionFailedCallBackInfo_->taskError_ = res;
task->ExecuteListenerCallback(task->onExecutionFailedCallBackInfo_);
}