Replace Signal with std::function. 38/260938/1
authorhuayong.xu <huayong.xu@samsung.com>
Wed, 7 Jul 2021 07:33:07 +0000 (15:33 +0800)
committerhuayong.xu <huayong.xu@samsung.com>
Wed, 7 Jul 2021 07:43:17 +0000 (15:43 +0800)
Originally Signal is used to notify webview when callback of web
engine is called. If Signal is called with a std::shared_ptr<X>,
lifecyle of object X would be managed by Signal only in
csharp-binder. So if Signal are destroyed, object X would be
destroyed too. This might cause some problem.
This patch is to replace Signal with std::fuction, and replace
std:shared_ptr with unique_ptr. Lifecycle of object X would not
be associated with that of Signal.

Change-Id: I3f4bdc2f58dd28444ab6640f7c8c4a56e037e83c

examples/web-view/web-view-example.cpp [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index b1aed6f..7351fa8
@@ -68,8 +68,8 @@ public:
     mWebView.SetProperty(Actor::Property::ANCHOR_POINT, Dali::AnchorPoint::CENTER);
     mWebView.SetProperty(Actor::Property::POSITION, Vector2(0, 0));
     mWebView.SetProperty(Actor::Property::SIZE, Vector2(width, height));
-    mWebView.PageLoadStartedSignal().Connect(this, &WebViewController::OnPageLoadStarted);
-    mWebView.PageLoadFinishedSignal().Connect(this, &WebViewController::OnPageLoadFinished);
+    mWebView.RegisterPageLoadStartedCallback(std::bind(&WebViewController::OnPageLoadStarted, this, std::placeholders::_1));
+    mWebView.RegisterPageLoadFinishedCallback(std::bind(&WebViewController::OnPageLoadFinished, this, std::placeholders::_1));
 
     std::string url = GetNextUrl();
     mWebView.LoadUrl(url);
@@ -88,12 +88,12 @@ public:
     Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor(mWebView);
   }
 
-  void OnPageLoadStarted(Toolkit::WebView view, const std::string& url)
+  void OnPageLoadStarted(const std::string& url)
   {
     mAddressLabel.SetProperty(Toolkit::TextLabel::Property::TEXT, "Loading");
   }
 
-  void OnPageLoadFinished(Toolkit::WebView view, const std::string& url)
+  void OnPageLoadFinished(const std::string& url)
   {
     mAddressLabel.SetProperty(Toolkit::TextLabel::Property::TEXT, url.c_str());
   }