Signed-off-by: wanning.fang <songruirui1@huawei.com>
This commit is contained in:
wanning.fang 2022-07-28 15:39:45 +08:00
parent 2d606da950
commit 293a5e592e
2 changed files with 8 additions and 12 deletions

View File

@ -40,8 +40,6 @@ public:
static napi_value Napi_NormalizeUri(napi_env env, napi_callback_info info);
static napi_value Napi_DenormalizeUri(napi_env env, napi_callback_info info);
static napi_value Napi_NotifyChange(napi_env env, napi_callback_info info);
void ReleaseObserverMap();
private:
static napi_value GetConstructor(napi_env env);
static napi_value Initialize(napi_env env, napi_callback_info info);

View File

@ -163,7 +163,14 @@ napi_value NapiDataShareHelper::Initialize(napi_env env, napi_callback_info info
auto finalize = [](napi_env env, void * data, void * hint) {
NapiDataShareHelper *proxy = reinterpret_cast<NapiDataShareHelper *>(data);
if (proxy != nullptr) {
proxy->ReleaseObserverMap();
auto it = proxy->observerMap_.begin();
while (it != proxy->observerMap_.end()) {
if (proxy->datashareHelper_ != nullptr) {
proxy->datashareHelper_->UnregisterObserver(Uri(it->first), it->second);
}
it->second->DeleteReference();
}
proxy->observerMap_.clear();
delete proxy;
}
};
@ -174,15 +181,6 @@ napi_value NapiDataShareHelper::Initialize(napi_env env, napi_callback_info info
return self;
}
void NapiDataShareHelper::ReleaseObserverMap()
{
auto it = this->observerMap_.begin();
while (it != this->observerMap_.end()) {
it->second->DeleteReference();
}
this->observerMap_.clear();
}
napi_value NapiDataShareHelper::Napi_OpenFile(napi_env env, napi_callback_info info)
{
LOG_DEBUG("Napi_OpenFile in");