提交 04835041 编写于 作者: 1 18392170496

remove cleanup hook

Signed-off-by: N18392170496 <magentang4@huawei.com>
上级 2b8dd22b
......@@ -52,7 +52,12 @@ NAPIRemoteObjectHolder::NAPIRemoteObjectHolder(napi_env env, const std::u16strin
NAPIRemoteObjectHolder::~NAPIRemoteObjectHolder()
{
napi_remove_env_cleanup_hook(env_, OnEnvCleanUp, this);
if (env_ != nullptr) {
napi_status status = napi_remove_env_cleanup_hook(env_, OnEnvCleanUp, this);
if (status != napi_ok) {
ZLOGE(LOG_LABEL, "remove cleanup hook failed");
}
}
}
sptr<IRemoteObject> NAPIRemoteObjectHolder::Get()
......@@ -95,6 +100,10 @@ napi_env NAPIRemoteObjectHolder::GetJsObjectEnv() const
void NAPIRemoteObjectHolder::CleanJsEnv()
{
napi_status status = napi_remove_env_cleanup_hook(env_, OnEnvCleanUp, this);
if (status != napi_ok) {
ZLOGE(LOG_LABEL, "remove cleanup hook failed");
}
env_ = nullptr;
jsObjectRef_ = nullptr;
sptr<IRemoteObject> tmp = wptrCachedObject_.promote();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册