From d5bb29f6e20ad347c74fb22d8907193f8a591952 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 14 Nov 2019 11:28:08 +0800 Subject: [PATCH] fix videoplayer crash in release mode --- cocos/ui/UIVideoPlayer-ios.mm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cocos/ui/UIVideoPlayer-ios.mm b/cocos/ui/UIVideoPlayer-ios.mm index 6a787e8216e6..2c67a74d50ec 100644 --- a/cocos/ui/UIVideoPlayer-ios.mm +++ b/cocos/ui/UIVideoPlayer-ios.mm @@ -110,6 +110,7 @@ -(void) dealloc -(void) clean { + _videoPlayer = nullptr; [self stop]; [self removePlayerEventListener]; [self.playerController.view removeFromSuperview]; @@ -243,7 +244,11 @@ -(void) stop [self seekTo:0]; [self.playerController.player pause]; _state = PlayerbackStopped; - _videoPlayer->onPlayEvent((int)VideoPlayer::EventType::STOPPED); + + // stop() will be invoked in dealloc, which is invoked by _videoPlayer's destructor, + // so do't send the message when _videoPlayer is being deleted. + if (_videoPlayer) + _videoPlayer->onPlayEvent((int)VideoPlayer::EventType::STOPPED); } }