!764 settingsdata CRASH问题修改

Merge pull request !764 from 侯志雄/master
This commit is contained in:
openharmony_ci 2024-09-30 02:38:19 +00:00 committed by Gitee
commit 49eabb7bc1
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -45,15 +45,6 @@ namespace Settings {
this->cbInfo = nullptr;
}
void SettingsObserver::EnvObserver(void* arg)
{
AsyncCallbackInfo* callBackInfo = reinterpret_cast<AsyncCallbackInfo*>(arg);
if (callBackInfo == nullptr || callBackInfo->env == nullptr) {
return;
}
callBackInfo->env = nullptr;
}
int OnChangeAsync(uv_loop_s* loop, uv_work_t *work)
{
int ret = uv_queue_work(loop, work, [](uv_work_t *work) {},
@ -88,8 +79,6 @@ namespace Settings {
&callResult);
napi_close_handle_scope(settingsObserver->cbInfo->env, scope);
SETTING_LOG_INFO("%{public}s, uv_work success.", __func__);
napi_remove_env_cleanup_hook(settingsObserver->cbInfo->env, SettingsObserver::EnvObserver,
settingsObserver->cbInfo);
delete work;
});
return ret;
@ -113,7 +102,6 @@ namespace Settings {
SETTING_LOG_ERROR("%{public}s, fail to get uv work.", __func__);
return;
}
napi_add_env_cleanup_hook(cbInfo->env, SettingsObserver::EnvObserver, this);
work->data = reinterpret_cast<void*>(this);
int ret = OnChangeAsync(loop, work);