Skip to content

Commit

Permalink
Fix dispatching of events when EventDispatcher is not initialized
Browse files Browse the repository at this point in the history
Summary:
This diff fixes a NPE that can occur when we force the dispatching of events when the EventDispatcher is not initized.

The fix consists on avoid posting the frame callback, if the internals of EventDispatcher are not initialized yet (same behavior used by the dispatchEvent method)

Reviewed By: fkgozali

Differential Revision: D13549147

fbshipit-source-id: ef3baeb536e8772fbd83024352a37af01c21d589
  • Loading branch information
mdvacca authored and facebook-github-bot committed Dec 27, 2018
1 parent acc2ed2 commit 5957c8b
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ public void dispatchEvent(Event event) {
event.getEventName(),
event.getUniqueID());
}
maybePostFrameCallbackFromNonUI();
}

public void dispatchAllEvents() {
maybePostFrameCallbackFromNonUI();
}

private void maybePostFrameCallbackFromNonUI() {
if (mReactEventEmitter != null) {
// If the host activity is paused, the frame callback may not be currently
// posted. Ensure that it is so that this event gets delivered promptly.
Expand All @@ -137,10 +145,6 @@ public void dispatchEvent(Event event) {
}
}

public void dispatchAllEvents() {
mCurrentFrameCallback.maybePostFromNonUI();
}

/**
* Add a listener to this EventDispatcher.
*/
Expand Down

0 comments on commit 5957c8b

Please sign in to comment.