Index: Source/bindings/dart/DartEventListener.cpp |
diff --git a/Source/bindings/dart/DartEventListener.cpp b/Source/bindings/dart/DartEventListener.cpp |
index 92602dedbb3295a30d6986a826fc9259a71e6933..95f21e9e9f3de58d111021fd693366cc99ca2d73 100644 |
--- a/Source/bindings/dart/DartEventListener.cpp |
+++ b/Source/bindings/dart/DartEventListener.cpp |
@@ -96,6 +96,8 @@ void DartEventListener::handleEvent(ScriptExecutionContext* context, Event* even |
// The callback function on XMLHttpRequest can clear the event listener and destroys 'this' object. Keep a local reference to it. |
// See issue 889829. |
RefPtr<DartEventListener> protect(this); |
+ // Keep a strong handle to the listener. |
+ Dart_Handle listener = Dart_HandleFromWeakPersistent(m_listener); |
// Get the Dart wrapper for the event object. |
Dart_Handle dartEvent = DartEvent::toDart(event); |
@@ -103,7 +105,7 @@ void DartEventListener::handleEvent(ScriptExecutionContext* context, Event* even |
// FIXME: consider if DateExtension manipulations are necessary and if yes (most probably), |
// factor out common logic. For example by introducing EventProcessScope RAII to manage DateExtension. |
- Dart_Handle result = callListenerFunction(context, dartEvent, event); |
+ Dart_Handle result = callListenerFunction(context, listener, dartEvent); |
if (Dart_IsError(result)) { |
DartUtilities::reportProblem(context, result); |
return; |
@@ -130,16 +132,16 @@ EventListener* DartEventListener::toNative(Dart_Handle handle, Dart_Handle& exce |
return createOrFetch(handle); |
} |
-Dart_Handle DartEventListener::callListenerFunction(ScriptExecutionContext* context, Dart_Handle dartEvent, Event* event) |
+Dart_Handle DartEventListener::callListenerFunction(ScriptExecutionContext* context, Dart_Handle listener, Dart_Handle dartEvent) |
{ |
- ASSERT(m_listener); |
+ ASSERT(listener); |
DartController* dartController = DartController::retrieve(context); |
if (!dartController) |
return Dart_Error("Internal error: failed to fetch Dart controller"); |
Dart_Handle parameters[1] = { dartEvent }; |
- return dartController->callFunction(Dart_HandleFromWeakPersistent(m_listener), 1, parameters); |
+ return dartController->callFunction(listener, 1, parameters); |
} |
} |