From d6de2220012a2e7cae832b860213cc512ae4e4d0 Mon Sep 17 00:00:00 2001 From: l30059571 Date: Tue, 4 Mar 2025 12:10:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=82=E6=AD=A5=E8=B0=83=E7=94=A8=E5=91=8A?= =?UTF-8?q?=E8=AD=A6=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: l30059571 --- frameworks/src/app_group_observer_napi.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/frameworks/src/app_group_observer_napi.cpp b/frameworks/src/app_group_observer_napi.cpp index e3ed903..42ec9a8 100644 --- a/frameworks/src/app_group_observer_napi.cpp +++ b/frameworks/src/app_group_observer_napi.cpp @@ -77,7 +77,7 @@ napi_value SetBundleGroupChangedData(const CallbackReceiveDataWorker *commonEven return BundleStateCommon::NapiGetNull(commonEventDataWorkerData->env); } -void UvQueueWorkOnAppGroupChanged(uv_work_t *work, int status) +void UvQueueWorkOnAppGroupChanged(uv_work_t *work) { BUNDLE_ACTIVE_LOGD("OnAppGroupChanged uv_work_t start"); if (!work) { @@ -151,10 +151,13 @@ ErrCode AppGroupObserver::OnAppGroupChanged(const AppGroupCallbackInfo &appGroup return ERR_OK; } MessageParcel data; - if (!appGroupCallbackInfo.Marshalling(data)) { - BUNDLE_ACTIVE_LOGE("Marshalling fail"); - } + if (!appGroupCallbackInfo.Marshalling(data)) {} AppGroupCallbackInfo* callBackInfo = appGroupCallbackInfo.Unmarshalling(data); + if (callBackInfo == nullptr) { + delete work; + work = nullptr; + return ERR_OK; + } callbackReceiveDataWorker->oldGroup = callBackInfo->GetOldGroup(); callbackReceiveDataWorker->newGroup = callBackInfo->GetNewGroup(); callbackReceiveDataWorker->changeReason = callBackInfo->GetChangeReason(); @@ -163,10 +166,12 @@ ErrCode AppGroupObserver::OnAppGroupChanged(const AppGroupCallbackInfo &appGroup callbackReceiveDataWorker->env = bundleGroupCallbackInfo_.env; callbackReceiveDataWorker->ref = bundleGroupCallbackInfo_.ref; delete callBackInfo; - work->data = static_cast(callbackReceiveDataWorker); - int ret = uv_queue_work(loop, work, [](uv_work_t *work) {}, UvQueueWorkOnAppGroupChanged); - if (ret != 0) { + auto task = [work]() { + UvQueueWorkOnAppGroupChanged(work); + }; + if (napi_status::napi_ok != napi_send_event(callbackReceiveDataWorker->env, task, napi_eprio_high)) { + BUNDLE_ACTIVE_LOGE("failed to napi_send_event"); delete callbackReceiveDataWorker; callbackReceiveDataWorker = nullptr; delete work; -- Gitee