Replace obsolete safe bool idiom with explicit operator bool 03/269403/4
authorArtur Świgoń <a.swigon@samsung.com>
Thu, 13 Jan 2022 16:45:50 +0000 (17:45 +0100)
committerArtur Świgoń <a.swigon@samsung.com>
Mon, 17 Jan 2022 09:27:39 +0000 (10:27 +0100)
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

dali-extension/camera-player/tizen-camera-player.cpp
dali-extension/video-player/ecore-wl/tizen-video-player-ecore-wl.cpp
dali-extension/video-player/ecore-wl2/tizen-video-player-ecore-wl2.cpp

index 50c7d42f7f0d9f60a365c1590f30f3facaad15e9..f4f8a838875ccfa72066a8af3e7adbcd1e70d029 100644 (file)
@@ -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;
index bdd65d8cec33269dbf283ea3f66a5e9f0f1ce819..454e84b38db50cf29fac4a12bf395378c8f9be78 100755 (executable)
@@ -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;
index 85c3f0b11ec9d5444a40b02c2ca112122ebea6a8..db9ab9483e4b5ee2f158092b5f5256a41b44a05c 100755 (executable)
@@ -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;