From: Artur Świgoń Date: Thu, 13 Jan 2022 16:45:50 +0000 (+0100) Subject: Replace obsolete safe bool idiom with explicit operator bool X-Git-Tag: submit/tizen/20220119.054331^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=56fcc34b1d6a9febefd8bd638e0d51f2619d7d79;p=platform%2Fcore%2Fuifw%2Fdali-extension.git Replace obsolete safe bool idiom with explicit operator bool C++11 introduces 'explicit operator bool' to prevent unintended implicit conversions to 'bool', thus making the trick with converting to a pointer-to-member (a.k.a. "safe bool idiom") obsolete. The explicit operator is more restrictive than 'safe bool', and it helped uncover a bug in the test suite where object handles were implicitly converted to bool before being sent to an std::ostream. Change-Id: Ib86383601d63acf1577130db9e4bca7dc486a323 --- diff --git a/dali-extension/camera-player/tizen-camera-player.cpp b/dali-extension/camera-player/tizen-camera-player.cpp index 50c7d42f..f4f8a838 100644 --- a/dali-extension/camera-player/tizen-camera-player.cpp +++ b/dali-extension/camera-player/tizen-camera-player.cpp @@ -194,7 +194,7 @@ void TizenCameraPlayer::StopPreview() int error = camera_stop_preview(mCameraPlayer); CameraPlayerError(error, __FUNCTION__, __LINE__); - if (mNativeImageSourcePtr != NULL && mTimer) + if (mNativeImageSourcePtr && mTimer) { mTimer.Stop(); DestroyPackets(); @@ -204,7 +204,7 @@ void TizenCameraPlayer::StopPreview() void TizenCameraPlayer::Destroy() { - if (mNativeImageSourcePtr != NULL && mTimer) + if (mNativeImageSourcePtr && mTimer) { mTimer.Stop(); DestroyPackets(); @@ -380,7 +380,7 @@ void TizenCameraPlayer::SetDisplayArea(DisplayArea area) { GetPlayerState(&mCameraPlayerState); - if (mNativeImageSourcePtr != NULL) + if (mNativeImageSourcePtr) { DALI_LOG_ERROR("SetDisplayArea is only for window surface target.\n"); return; diff --git a/dali-extension/video-player/ecore-wl/tizen-video-player-ecore-wl.cpp b/dali-extension/video-player/ecore-wl/tizen-video-player-ecore-wl.cpp index bdd65d8c..454e84b3 100755 --- a/dali-extension/video-player/ecore-wl/tizen-video-player-ecore-wl.cpp +++ b/dali-extension/video-player/ecore-wl/tizen-video-player-ecore-wl.cpp @@ -373,7 +373,7 @@ void TizenVideoPlayer::Play() if( mPlayerState == PLAYER_STATE_READY || mPlayerState == PLAYER_STATE_PAUSED ) { - if( mNativeImageSourcePtr != NULL && mTimer ) + if( mNativeImageSourcePtr && mTimer ) { mTimer.Start(); } @@ -392,7 +392,7 @@ void TizenVideoPlayer::Pause() int error = player_pause( mPlayer ); LogPlayerError( error ); - if( mNativeImageSourcePtr != NULL && mTimer ) + if( mNativeImageSourcePtr && mTimer ) { mTimer.Stop(); DestroyPackets(); @@ -409,7 +409,7 @@ void TizenVideoPlayer::Stop() int error = player_stop( mPlayer ); LogPlayerError( error ); - if( mNativeImageSourcePtr != NULL && mTimer ) + if( mNativeImageSourcePtr && mTimer ) { mTimer.Stop(); DestroyPackets(); @@ -512,7 +512,7 @@ int TizenVideoPlayer::GetPlayPosition() void TizenVideoPlayer::SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation ) { - if( mNativeImageSourcePtr != NULL ) + if( mNativeImageSourcePtr ) { DALI_LOG_ERROR( "SetDisplayRotation is only for window rendering target.\n" ); return; @@ -528,7 +528,7 @@ void TizenVideoPlayer::SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotat Dali::VideoPlayerPlugin::DisplayRotation TizenVideoPlayer::GetDisplayRotation() { - if( mNativeImageSourcePtr != NULL ) + if( mNativeImageSourcePtr ) { DALI_LOG_ERROR( "GetDisplayRotation is only for window rendering target.\n" ); return Dali::VideoPlayerPlugin::ROTATION_NONE; @@ -711,7 +711,7 @@ void TizenVideoPlayer::SetDisplayArea( DisplayArea area ) { GetPlayerState( &mPlayerState ); - if( mNativeImageSourcePtr != NULL ) + if( mNativeImageSourcePtr ) { DALI_LOG_ERROR( "SetDisplayArea is only for window surface target.\n" ); return; diff --git a/dali-extension/video-player/ecore-wl2/tizen-video-player-ecore-wl2.cpp b/dali-extension/video-player/ecore-wl2/tizen-video-player-ecore-wl2.cpp index 85c3f0b1..db9ab948 100755 --- a/dali-extension/video-player/ecore-wl2/tizen-video-player-ecore-wl2.cpp +++ b/dali-extension/video-player/ecore-wl2/tizen-video-player-ecore-wl2.cpp @@ -484,7 +484,7 @@ void TizenVideoPlayer::Play() if(mPlayerState == PLAYER_STATE_READY || mPlayerState == PLAYER_STATE_PAUSED) { - if(mNativeImageSourcePtr != NULL && mTimer) + if(mNativeImageSourcePtr && mTimer) { mTimer.Start(); } @@ -511,7 +511,7 @@ void TizenVideoPlayer::Pause() DALI_LOG_ERROR("Pause, player_pause() is failed\n"); } - if(mNativeImageSourcePtr != NULL && mTimer) + if(mNativeImageSourcePtr && mTimer) { mTimer.Stop(); DestroyPackets(); @@ -532,7 +532,7 @@ void TizenVideoPlayer::Stop() DALI_LOG_ERROR("Stop, player_stop() is failed\n"); } - if(mNativeImageSourcePtr != NULL && mTimer) + if(mNativeImageSourcePtr && mTimer) { mTimer.Stop(); DestroyPackets(); @@ -660,7 +660,7 @@ int TizenVideoPlayer::GetPlayPosition() void TizenVideoPlayer::SetDisplayRotation(Dali::VideoPlayerPlugin::DisplayRotation rotation) { - if(mNativeImageSourcePtr != NULL) + if(mNativeImageSourcePtr) { DALI_LOG_ERROR("SetDisplayRotation is only for window rendering target.\n"); return; @@ -680,7 +680,7 @@ void TizenVideoPlayer::SetDisplayRotation(Dali::VideoPlayerPlugin::DisplayRotati Dali::VideoPlayerPlugin::DisplayRotation TizenVideoPlayer::GetDisplayRotation() { - if(mNativeImageSourcePtr != NULL) + if(mNativeImageSourcePtr) { DALI_LOG_ERROR("GetDisplayRotation is only for window rendering target.\n"); return Dali::VideoPlayerPlugin::ROTATION_NONE; @@ -1045,7 +1045,7 @@ void TizenVideoPlayer::SetDisplayArea(DisplayArea area) int ret = 0; GetPlayerState(&mPlayerState); - if(mNativeImageSourcePtr != NULL) + if(mNativeImageSourcePtr) { DALI_LOG_ERROR("SetDisplayArea is only for window surface target.\n"); return;