From 51c32f68489eac3b7617d5d491b35069cf3746dc Mon Sep 17 00:00:00 2001 From: huangzhenghua Date: Wed, 15 Mar 2023 22:03:03 +0800 Subject: [PATCH] bugfix of napi hap crash issue: https://gitee.com/openharmony/xts_acts/issues/I6NHMQ Signed-off-by: huangzhenghua Change-Id: I0d5f8c2e25c09d6c53603d2c687752a5344aa650 --- .../entry/src/main/cpp/napi/napi_test.cpp | 3 --- .../src/main/ets/test/NativeApiStringTest.ets | 23 +++++++++++++------ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/arkui/ace_napi_test/entry/src/main/cpp/napi/napi_test.cpp b/arkui/ace_napi_test/entry/src/main/cpp/napi/napi_test.cpp index e23b298e2..20740aaf9 100644 --- a/arkui/ace_napi_test/entry/src/main/cpp/napi/napi_test.cpp +++ b/arkui/ace_napi_test/entry/src/main/cpp/napi/napi_test.cpp @@ -1862,9 +1862,6 @@ static void AddPromiseCompleteCB(napi_env env, napi_status status, void *data) { } else { NAPI_CALL_RETURN_VOID(env, napi_reject_deferred(env, addonData->deferred, result)); } - if (addonData->callback != nullptr) { - NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, addonData->callback)); - } NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, addonData->asyncWork)); free(addonData); diff --git a/arkui/ace_napi_test/entry/src/main/ets/test/NativeApiStringTest.ets b/arkui/ace_napi_test/entry/src/main/ets/test/NativeApiStringTest.ets index 6656f1636..6e462b33a 100644 --- a/arkui/ace_napi_test/entry/src/main/ets/test/NativeApiStringTest.ets +++ b/arkui/ace_napi_test/entry/src/main/ets/test/NativeApiStringTest.ets @@ -1115,17 +1115,26 @@ export default function nativeApiStringJsunit() { console.info('aceNapiTest079 START'); value = napitest.testPromise(1).then( (result)=>{ - console.info('aceNapiTest079 testString result is: ' + result + "--" + JSON.stringify(result)); - expect(result > 0).assertTrue(); + console.info('aceNapiTest079 testString resolve1 result is: ' + result + "--" + JSON.stringify(result)); + expect(result > 0).assertTrue(); + done(); + }, (result) =>{ + console.info('aceNapiTest079 testString reject1 result is: ' + result + "--" + JSON.stringify(result)); + expect(result < 0).assertTrue(); + done(); } ); value = napitest.testPromise(-1).then( - (result)=>{ - console.info('aceNapiTest079 testString result is: ' + result + "--" + JSON.stringify(result)); - expect(result > 0).assertTrue(); - } + (result)=>{ + console.info('aceNapiTest079 testString resolve2 result is: ' + result + "--" + JSON.stringify(result)); + expect(result > 0).assertTrue(); + done(); + }, (result) =>{ + console.info('aceNapiTest079 testString reject2 result is: ' + result + "--" + JSON.stringify(result)); + expect(result < 0).assertTrue(); + done(); + } ); - done(); }); /** -- GitLab