From 477e20de0c233000993e19f8eb5fb19302f7a1bf Mon Sep 17 00:00:00 2001 From: tianp Date: Mon, 4 Aug 2025 16:15:45 +0800 Subject: [PATCH] =?UTF-8?q?watcheventlistener=E6=8E=A5=E5=8F=A3=E6=95=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tianp Change-Id: I993867482d289d19508aeedfe26ba8394910291b --- .../src/mod_fs/class_watcher/ani/watch_event_listener.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/js/src/mod_fs/class_watcher/ani/watch_event_listener.cpp b/interfaces/kits/js/src/mod_fs/class_watcher/ani/watch_event_listener.cpp index 36ac7517d..d51d6a44a 100644 --- a/interfaces/kits/js/src/mod_fs/class_watcher/ani/watch_event_listener.cpp +++ b/interfaces/kits/js/src/mod_fs/class_watcher/ani/watch_event_listener.cpp @@ -79,17 +79,20 @@ void WatchEventListener::SendWatchEvent(const WatchEvent &watchEvent) const HILOGE("Cannot send WatchEvent because the callback is null."); return; } - ani_size scopeSize = ANI_SCOPE_SIZE; + ani_env *env = AniHelper::GetThreadEnv(vm); if (env == nullptr) { HILOGE("Cannot send WatchEvent because the env is null."); return; } + + ani_size scopeSize = ANI_SCOPE_SIZE; ani_status status = env->CreateLocalScope(scopeSize); if (status != ANI_OK) { HILOGE("Failed to creat local scope, status: %{public}d", static_cast(status)); return; } + auto evtObj = WatchEventWrapper::Wrap(env, watchEvent); if (evtObj == nullptr) { HILOGE("Create WatchEvent obj failed!"); @@ -102,7 +105,6 @@ void WatchEventListener::SendWatchEvent(const WatchEvent &watchEvent) const status = env->FunctionalObject_Call(cbObj, argc, args.data(), &result); if (status != ANI_OK) { HILOGE("Failed to call FunctionalObject_Call, status: %{public}d", static_cast(status)); - // continue execution and not exit. } status = env->DestroyLocalScope(); if (status != ANI_OK) { -- Gitee