Fix minor coverity issues (phase 2) 91/300391/1
authorEunki Hong <eunkiki.hong@samsung.com>
Mon, 23 Oct 2023 11:34:24 +0000 (20:34 +0900)
committerEunki Hong <eunkiki.hong@samsung.com>
Mon, 23 Oct 2023 11:34:24 +0000 (20:34 +0900)
 - Move std::string
 - Move std::function
 - Move some Property::Map if possible

Change-Id: I1400f02aa30e37b71a8d731d108bdf41acd88e1c
Signed-off-by: Eunki Hong <eunkiki.hong@samsung.com>
dali-toolkit/internal/controls/popup/popup-impl.cpp
dali-toolkit/internal/controls/text-controls/common-text-utils.cpp
dali-toolkit/internal/controls/web-view/web-view-impl.cpp

index bc65701..9c9a1f2 100644 (file)
@@ -1084,7 +1084,7 @@ const Vector4& Popup::GetBackingColor() const
 
 void Popup::SetTailUpImage(std::string image)
 {
-  mTailUpImage = image;
+  mTailUpImage = std::move(image);
   mLayoutDirty = true;
   LayoutTail();
 }
@@ -1096,7 +1096,7 @@ const std::string& Popup::GetTailUpImage() const
 
 void Popup::SetTailDownImage(std::string image)
 {
-  mTailDownImage = image;
+  mTailDownImage = std::move(image);
   mLayoutDirty   = true;
   LayoutTail();
 }
@@ -1108,7 +1108,7 @@ const std::string& Popup::GetTailDownImage() const
 
 void Popup::SetTailLeftImage(std::string image)
 {
-  mTailLeftImage = image;
+  mTailLeftImage = std::move(image);
   mLayoutDirty   = true;
   LayoutTail();
 }
@@ -1120,7 +1120,7 @@ const std::string& Popup::GetTailLeftImage() const
 
 void Popup::SetTailRightImage(std::string image)
 {
-  mTailRightImage = image;
+  mTailRightImage = std::move(image);
   mLayoutDirty    = true;
   LayoutTail();
 }
@@ -1306,7 +1306,7 @@ void Popup::SetProperty(BaseObject* object, Property::Index propertyIndex, const
         std::string valueString;
         if(value.Get(valueString))
         {
-          Toolkit::ImageView actor = Toolkit::ImageView::New(valueString);
+          Toolkit::ImageView actor = Toolkit::ImageView::New(std::move(valueString));
           popupImpl.SetPopupBackgroundImage(actor);
         }
         break;
@@ -1341,7 +1341,7 @@ void Popup::SetProperty(BaseObject* object, Property::Index propertyIndex, const
         std::string valueString;
         if(value.Get(valueString))
         {
-          popupImpl.SetTailUpImage(valueString);
+          popupImpl.SetTailUpImage(std::move(valueString));
         }
         break;
       }
@@ -1350,7 +1350,7 @@ void Popup::SetProperty(BaseObject* object, Property::Index propertyIndex, const
         std::string valueString;
         if(value.Get(valueString))
         {
-          popupImpl.SetTailDownImage(valueString);
+          popupImpl.SetTailDownImage(std::move(valueString));
         }
         break;
       }
@@ -1359,7 +1359,7 @@ void Popup::SetProperty(BaseObject* object, Property::Index propertyIndex, const
         std::string valueString;
         if(value.Get(valueString))
         {
-          popupImpl.SetTailLeftImage(valueString);
+          popupImpl.SetTailLeftImage(std::move(valueString));
         }
         break;
       }
@@ -1368,7 +1368,7 @@ void Popup::SetProperty(BaseObject* object, Property::Index propertyIndex, const
         std::string valueString;
         if(value.Get(valueString))
         {
-          popupImpl.SetTailRightImage(valueString);
+          popupImpl.SetTailRightImage(std::move(valueString));
         }
         break;
       }
@@ -1392,21 +1392,21 @@ Property::Value Popup::GetProperty(BaseObject* object, Property::Index propertyI
       {
         Property::Map map;
         Scripting::CreatePropertyMap(popupImpl.GetTitle(), map);
-        value = map;
+        value = std::move(map);
         break;
       }
       case Toolkit::Popup::Property::CONTENT:
       {
         Property::Map map;
         Scripting::CreatePropertyMap(popupImpl.GetContent(), map);
-        value = map;
+        value = std::move(map);
         break;
       }
       case Toolkit::Popup::Property::FOOTER:
       {
         Property::Map map;
         Scripting::CreatePropertyMap(popupImpl.GetFooter(), map);
-        value = map;
+        value = std::move(map);
         break;
       }
       case Toolkit::Popup::Property::DISPLAY_STATE:
@@ -1448,14 +1448,14 @@ Property::Value Popup::GetProperty(BaseObject* object, Property::Index propertyI
       {
         // Note: Cannot retrieve property map from animation.
         Property::Map map;
-        value = map;
+        value = std::move(map);
         break;
       }
       case Toolkit::Popup::Property::EXIT_ANIMATION:
       {
         // Note: Cannot retrieve property map from animation.
         Property::Map map;
-        value = map;
+        value = std::move(map);
         break;
       }
       case Toolkit::Popup::Property::AUTO_HIDE_DELAY:
@@ -2003,7 +2003,7 @@ std::string Popup::PopupAccessible::GetNameRaw() const
   if(popupTitle)
   {
     std::string titleText = popupTitle.GetProperty<std::string>(Toolkit::TextLabel::Property::TEXT);
-    title                 = titleText;
+    title                 = std::move(titleText);
   }
   else
   {
@@ -2011,7 +2011,7 @@ std::string Popup::PopupAccessible::GetNameRaw() const
     if(popupContent)
     {
       std::string contentText = popupContent.GetProperty<std::string>(Toolkit::TextLabel::Property::TEXT);
-      title                   = contentText;
+      title                   = std::move(contentText);
     }
   }
   return title;
index 6ece809..b18cb98 100644 (file)
@@ -203,7 +203,7 @@ Accessibility::Range TextControlAccessible::GetRangeOfSelection(std::size_t sele
   auto endOffset   = static_cast<std::size_t>(indices.second);
   auto text        = GetText(startOffset, endOffset);
 
-  return {startOffset, endOffset, text};
+  return {startOffset, endOffset, std::move(text)};
 }
 
 std::string TextControlAccessible::GetText(std::size_t startOffset, std::size_t endOffset) const
index 987f297..696b8e2 100644 (file)
@@ -490,7 +490,7 @@ void WebView::EvaluateJavaScript(const std::string& script, std::function<void(c
 {
   if(mWebEngine)
   {
-    mWebEngine.EvaluateJavaScript(script, resultHandler);
+    mWebEngine.EvaluateJavaScript(script, std::move(resultHandler));
   }
 }
 
@@ -498,7 +498,7 @@ void WebView::AddJavaScriptMessageHandler(const std::string& exposedObjectName,
 {
   if(mWebEngine)
   {
-    mWebEngine.AddJavaScriptMessageHandler(exposedObjectName, handler);
+    mWebEngine.AddJavaScriptMessageHandler(exposedObjectName, std::move(handler));
   }
 }
 
@@ -506,7 +506,7 @@ void WebView::RegisterJavaScriptAlertCallback(Dali::WebEnginePlugin::JavaScriptA
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterJavaScriptAlertCallback(callback);
+    mWebEngine.RegisterJavaScriptAlertCallback(std::move(callback));
   }
 }
 
@@ -522,7 +522,7 @@ void WebView::RegisterJavaScriptConfirmCallback(Dali::WebEnginePlugin::JavaScrip
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterJavaScriptConfirmCallback(callback);
+    mWebEngine.RegisterJavaScriptConfirmCallback(std::move(callback));
   }
 }
 
@@ -538,7 +538,7 @@ void WebView::RegisterJavaScriptPromptCallback(Dali::WebEnginePlugin::JavaScript
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterJavaScriptPromptCallback(callback);
+    mWebEngine.RegisterJavaScriptPromptCallback(std::move(callback));
   }
 }
 
@@ -566,7 +566,7 @@ bool WebView::CreateHitTestAsynchronously(int32_t x, int32_t y, Dali::WebEngineH
   bool result = false;
   if(mWebEngine)
   {
-    result = mWebEngine.CreateHitTestAsynchronously(x, y, mode, callback);
+    result = mWebEngine.CreateHitTestAsynchronously(x, y, mode, std::move(callback));
   }
   return result;
 }
@@ -634,20 +634,20 @@ Dali::Toolkit::ImageView WebView::GetScreenshot(Dali::Rect<int32_t> viewArea, fl
 
 bool WebView::GetScreenshotAsynchronously(Dali::Rect<int32_t> viewArea, float scaleFactor, Dali::Toolkit::WebView::WebViewScreenshotCapturedCallback callback)
 {
-  mScreenshotCapturedCallback = callback;
+  mScreenshotCapturedCallback = std::move(callback);
   return mWebEngine ? mWebEngine.GetScreenshotAsynchronously(viewArea, scaleFactor, std::bind(&WebView::OnScreenshotCaptured, this, std::placeholders::_1)) : false;
 }
 
 bool WebView::CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback)
 {
-  return mWebEngine ? mWebEngine.CheckVideoPlayingAsynchronously(callback) : false;
+  return mWebEngine ? mWebEngine.CheckVideoPlayingAsynchronously(std::move(callback)) : false;
 }
 
 void WebView::RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback)
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterGeolocationPermissionCallback(callback);
+    mWebEngine.RegisterGeolocationPermissionCallback(std::move(callback));
   }
 }
 
@@ -698,7 +698,7 @@ void WebView::RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePa
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterPageLoadStartedCallback(callback);
+    mWebEngine.RegisterPageLoadStartedCallback(std::move(callback));
   }
 }
 
@@ -706,7 +706,7 @@ void WebView::RegisterPageLoadInProgressCallback(Dali::WebEnginePlugin::WebEngin
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterPageLoadInProgressCallback(callback);
+    mWebEngine.RegisterPageLoadInProgressCallback(std::move(callback));
   }
 }
 
@@ -714,7 +714,7 @@ void WebView::RegisterPageLoadFinishedCallback(Dali::WebEnginePlugin::WebEngineP
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterPageLoadFinishedCallback(callback);
+    mWebEngine.RegisterPageLoadFinishedCallback(std::move(callback));
   }
 }
 
@@ -722,7 +722,7 @@ void WebView::RegisterPageLoadErrorCallback(Dali::WebEnginePlugin::WebEnginePage
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterPageLoadErrorCallback(callback);
+    mWebEngine.RegisterPageLoadErrorCallback(std::move(callback));
   }
 }
 
@@ -730,7 +730,7 @@ void WebView::RegisterScrollEdgeReachedCallback(Dali::WebEnginePlugin::WebEngine
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterScrollEdgeReachedCallback(callback);
+    mWebEngine.RegisterScrollEdgeReachedCallback(std::move(callback));
   }
 }
 
@@ -738,7 +738,7 @@ void WebView::RegisterUrlChangedCallback(Dali::WebEnginePlugin::WebEngineUrlChan
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterUrlChangedCallback(callback);
+    mWebEngine.RegisterUrlChangedCallback(std::move(callback));
   }
 }
 
@@ -746,20 +746,20 @@ void WebView::RegisterFormRepostDecidedCallback(Dali::WebEnginePlugin::WebEngine
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterFormRepostDecidedCallback(callback);
+    mWebEngine.RegisterFormRepostDecidedCallback(std::move(callback));
   }
 }
 
 void WebView::RegisterFrameRenderedCallback(Dali::WebEnginePlugin::WebEngineFrameRenderedCallback callback)
 {
-  mFrameRenderedCallback = callback;
+  mFrameRenderedCallback = std::move(callback);
 }
 
 void WebView::RegisterConsoleMessageReceivedCallback(Dali::WebEnginePlugin::WebEngineConsoleMessageReceivedCallback callback)
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterConsoleMessageReceivedCallback(callback);
+    mWebEngine.RegisterConsoleMessageReceivedCallback(std::move(callback));
   }
 }
 
@@ -767,7 +767,7 @@ void WebView::RegisterResponsePolicyDecidedCallback(Dali::WebEnginePlugin::WebEn
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterResponsePolicyDecidedCallback(callback);
+    mWebEngine.RegisterResponsePolicyDecidedCallback(std::move(callback));
   }
 }
 
@@ -775,7 +775,7 @@ void WebView::RegisterNavigationPolicyDecidedCallback(Dali::WebEnginePlugin::Web
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterNavigationPolicyDecidedCallback(callback);
+    mWebEngine.RegisterNavigationPolicyDecidedCallback(std::move(callback));
   }
 }
 
@@ -783,7 +783,7 @@ void WebView::RegisterNewWindowCreatedCallback(Dali::WebEnginePlugin::WebEngineN
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterNewWindowCreatedCallback(callback);
+    mWebEngine.RegisterNewWindowCreatedCallback(std::move(callback));
   }
 }
 
@@ -791,7 +791,7 @@ void WebView::RegisterCertificateConfirmedCallback(Dali::WebEnginePlugin::WebEng
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterCertificateConfirmedCallback(callback);
+    mWebEngine.RegisterCertificateConfirmedCallback(std::move(callback));
   }
 }
 
@@ -799,7 +799,7 @@ void WebView::RegisterSslCertificateChangedCallback(Dali::WebEnginePlugin::WebEn
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterSslCertificateChangedCallback(callback);
+    mWebEngine.RegisterSslCertificateChangedCallback(std::move(callback));
   }
 }
 
@@ -807,7 +807,7 @@ void WebView::RegisterHttpAuthHandlerCallback(Dali::WebEnginePlugin::WebEngineHt
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterHttpAuthHandlerCallback(callback);
+    mWebEngine.RegisterHttpAuthHandlerCallback(std::move(callback));
   }
 }
 
@@ -815,7 +815,7 @@ void WebView::RegisterContextMenuShownCallback(Dali::WebEnginePlugin::WebEngineC
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterContextMenuShownCallback(callback);
+    mWebEngine.RegisterContextMenuShownCallback(std::move(callback));
   }
 }
 
@@ -823,7 +823,7 @@ void WebView::RegisterContextMenuHiddenCallback(Dali::WebEnginePlugin::WebEngine
 {
   if(mWebEngine)
   {
-    mWebEngine.RegisterContextMenuHiddenCallback(callback);
+    mWebEngine.RegisterContextMenuHiddenCallback(std::move(callback));
   }
 }
 
@@ -831,7 +831,7 @@ void WebView::GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceive
 {
   if(mWebEngine)
   {
-    mWebEngine.GetPlainTextAsynchronously(callback);
+    mWebEngine.GetPlainTextAsynchronously(std::move(callback));
   }
 }