Skip to content

Commit

Permalink
Fabric: Checking an EventEmitter before calling in RCTModalHostViewCo…
Browse files Browse the repository at this point in the history
…mponentView

Summary: We need to check if `_eventEmitter` is not nullptr before each call on it.

Reviewed By: sammy-SC

Differential Revision: D17531070

fbshipit-source-id: e9b5608845c10c7c2ef38f43c8deb67dad10fb6f
  • Loading branch information
shergin authored and facebook-github-bot committed Sep 28, 2019
1 parent a35a3ec commit ba8b6a7
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,13 @@ - (void)ensurePresentedOnlyIfNeeded
presentViewController:_viewController
animated:_shouldAnimatePresentation
completion:^{
ModalHostViewOnShowStruct onShow;
std::dynamic_pointer_cast<const ModalHostViewEventEmitter>(self->_eventEmitter)->onShow(onShow);
if (!self->_eventEmitter) {
return;
}

assert(std::dynamic_pointer_cast<ModalHostViewEventEmitter const>(self->_eventEmitter));
auto eventEmitter = std::static_pointer_cast<ModalHostViewEventEmitter const>(self->_eventEmitter);
eventEmitter->onShow(ModalHostViewOnShowStruct{});
}];
}

Expand All @@ -156,8 +161,12 @@ - (void)didMoveToSuperview

- (void)boundsDidChange:(CGRect)newBounds
{
std::dynamic_pointer_cast<const ModalHostViewEventEmitter>(_eventEmitter)
->onOrientationChange(onOrientationChangeStruct(newBounds));
if (_eventEmitter) {
assert(std::dynamic_pointer_cast<ModalHostViewEventEmitter const>(_eventEmitter));

auto eventEmitter = std::static_pointer_cast<ModalHostViewEventEmitter const>(_eventEmitter);
eventEmitter->onOrientationChange(onOrientationChangeStruct(newBounds));
}

if (_state != nullptr) {
auto newState = ModalHostViewState{RCTSizeFromCGSize(newBounds.size)};
Expand Down

0 comments on commit ba8b6a7

Please sign in to comment.