diff --git a/frameworks/src/core/base/event_util.cpp b/frameworks/src/core/base/event_util.cpp index 9c0eed6..5612e08 100755 --- a/frameworks/src/core/base/event_util.cpp +++ b/frameworks/src/core/base/event_util.cpp @@ -52,6 +52,7 @@ void CallbackExecutor(void *data) JSValue args[argsLength] = {params->arg}; JSRelease(JSFunction::Call(params->fn, params->vm, args, argsLength)); JSRelease(params->arg); + JSRelease(params->vm); delete params; params = nullptr; } @@ -126,6 +127,7 @@ void EventUtil::InvokeCallback(JSValue vm, JSValue callback, JSValue event, cons HILOG_ERROR(HILOG_MODULE_ACE, "EventUtil::InvokeCallback failed: Async task dispatch failure."); delete params; params = nullptr; + JSRelease(vm); JSRelease(event); } } diff --git a/frameworks/src/core/components/event_listener.cpp b/frameworks/src/core/components/event_listener.cpp index 9348f80..24267ae 100755 --- a/frameworks/src/core/components/event_listener.cpp +++ b/frameworks/src/core/components/event_listener.cpp @@ -146,8 +146,8 @@ bool ViewOnSwipeListener::OnDragEnd(UIView& view, const DragEvent &event) HILOG_DEBUG(HILOG_MODULE_ACE, "OnDragEnd received"); JSValue arg = EventUtil::CreateSwipeEvent(view, event); - EventUtil::InvokeCallback(JSUndefined::Create(), fn_, arg, this); - + JSValue vm = GetRootAbilitySlice(); + EventUtil::InvokeCallback(vm, fn_, arg, this); return isStopPropagation_; } } // namespace ACELite diff --git a/frameworks/src/core/components/event_listener.h b/frameworks/src/core/components/event_listener.h index ae91634..a95f832 100755 --- a/frameworks/src/core/components/event_listener.h +++ b/frameworks/src/core/components/event_listener.h @@ -108,7 +108,8 @@ public: return isStopPropagation_; } JSValue arg = EventUtil::CreateEvent(EventUtil::EVENT_CLICK, view, event); - EventUtil::InvokeCallback(JSUndefined::Create(), fn_, arg, this); + JSValue vm = GetRootAbilitySlice(); + EventUtil::InvokeCallback(vm, fn_, arg, this); return isStopPropagation_; } @@ -143,7 +144,8 @@ public: } JSValue arg = EventUtil::CreateEvent(EventUtil::EVENT_LONGPRESS, view, event); - EventUtil::InvokeCallback(JSUndefined::Create(), fn_, arg, this); + JSValue vm = GetRootAbilitySlice(); + EventUtil::InvokeCallback(vm, fn_, arg, this); return isStopPropagation_; }