diff --git a/interfaces/napi/kits/device/js_device.cpp b/interfaces/napi/kits/device/js_device.cpp index 6eaf819d86c1ab65f5793cda9f6771ff990a9119..88f631470d984487fcddeae7224f38feb17e4135 100644 --- a/interfaces/napi/kits/device/js_device.cpp +++ b/interfaces/napi/kits/device/js_device.cpp @@ -132,8 +132,8 @@ static napi_value JSGetInfo(napi_env env, napi_callback_info info) napi_value ret; napi_call_function(env, nullptr, callback, 0, nullptr, &ret); napi_delete_reference(env, asyncContext->cmpCallbackRef); - napi_delete_async_work(env, asyncContext->work); } + napi_delete_async_work(env, asyncContext->work); delete asyncContext; }, (void*)asyncContext, &asyncContext->work); diff --git a/interfaces/napi/kits/prompt/js_prompt.cpp b/interfaces/napi/kits/prompt/js_prompt.cpp index 25f694970b6933163dc4f143c199b8527b377f60..9f94cf96a992a65588d8d1a05285a6686c1c1d58 100644 --- a/interfaces/napi/kits/prompt/js_prompt.cpp +++ b/interfaces/napi/kits/prompt/js_prompt.cpp @@ -326,9 +326,11 @@ static napi_value JSPromptShowDialog(napi_env env, napi_callback_info info) napi_call_function(env, nullptr, callback, 1, &result, &ret); napi_delete_reference(env, asyncContext->callbackComplete); } + napi_delete_async_work(env, asyncContext->work); delete asyncContext; break; default: + napi_delete_async_work(env, asyncContext->work); delete asyncContext; break; } @@ -491,6 +493,8 @@ static napi_value JSPromptShowActionMenu(napi_env env, napi_callback_info info) napi_call_function(env, nullptr, callback, 1, &returnObj, &ret); napi_delete_reference(env, asyncContext->callbackComplete); } + napi_delete_async_work(env, asyncContext->work); + delete asyncContext; } else { auto callBack = [env, asyncContext](int32_t callbackType, int32_t successType) { napi_value ret; @@ -532,6 +536,7 @@ static napi_value JSPromptShowActionMenu(napi_env env, napi_callback_info info) default: break; } + napi_delete_async_work(env, asyncContext->work); delete asyncContext; }; jsEngine->GetFrontend()->ShowActionMenu( diff --git a/interfaces/napi/kits/router/js_router.cpp b/interfaces/napi/kits/router/js_router.cpp index 180f707304097a3a4cad8ecb9e2eaa27db6fb397..0b28b7672638d2827dc5b09d24cc7a6c2eb13ec9 100644 --- a/interfaces/napi/kits/router/js_router.cpp +++ b/interfaces/napi/kits/router/js_router.cpp @@ -315,6 +315,8 @@ static napi_value JSRouterEnableAlertBeforeBackPage(napi_env env, napi_callback_ napi_call_function(env, nullptr, callback, 1, &returnObj, &ret); napi_delete_reference(env, asyncContext->callbackComplete); } + napi_delete_async_work(env, asyncContext->work); + delete asyncContext; } else { auto callBack = [env, asyncContext](int32_t callbackType) { napi_value ret; @@ -358,6 +360,7 @@ static napi_value JSRouterEnableAlertBeforeBackPage(napi_env env, napi_callback_ LOGE("callbackType is invalid"); break; } + napi_delete_async_work(env, asyncContext->work); delete asyncContext; }; jsEngine->GetFrontend()->EnableAlertBeforeBackPage(asyncContext->messageString, std::move(callBack)); @@ -441,6 +444,7 @@ static napi_value JSRouterDisableAlertBeforeBackPage(napi_env env, napi_callback napi_call_function(env, nullptr, callback, 1, &returnObj, &ret); napi_delete_reference(env, asyncContext->callbackFail); } + napi_delete_async_work(env, asyncContext->work); delete asyncContext; }, (void*)disableRouterAsyncContext, &disableRouterAsyncContext->work);