Fabric: Checking an EventEmitter before calling in RCTModalHostViewComponentView

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
This commit is contained in:
Valentin Shergin 2019-09-28 15:08:30 -07:00 коммит произвёл Facebook Github Bot
Родитель a35a3ec157
Коммит ba8b6a77a6
1 изменённых файлов: 13 добавлений и 4 удалений

Просмотреть файл

@ -129,8 +129,13 @@ static ModalHostViewOnOrientationChangeStruct onOrientationChangeStruct(CGRect r
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{});
}];
}
@ -156,8 +161,12 @@ static ModalHostViewOnOrientationChangeStruct onOrientationChangeStruct(CGRect r
- (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)};