Fix Launcher Service 10/230510/1
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 10 Apr 2020 07:18:14 +0000 (16:18 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 10 Apr 2020 07:18:22 +0000 (16:18 +0900)
- Fixes fd leak

Change-Id: Ice442c510b76a1dc0026d8b9a41a07ddb723a80b
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
screen_connector_launcher_service/launcher_service.cc

index 82eaae9..6d31d80 100644 (file)
@@ -87,7 +87,7 @@ void LauncherService::Impl::OnRawBufferChanged(uint32_t type,
     int32_t y,
     const std::string& shared_widget_info,
     uint32_t serial) {
-
+  auto image_file = std::shared_ptr<ImageFile>(new ImageFile(fd, size));
   if (done_) {
     _W("Skip");
     return;
@@ -99,8 +99,7 @@ void LauncherService::Impl::OnRawBufferChanged(uint32_t type,
     listener_->OnPrepareEvent(raw_image_, serial);
   } else if (type == TIZEN_REMOTE_SURFACE_BUFFER_TYPE_IMAGE_FILE) {
     raw_image_ = std::shared_ptr<RawImage>(new RawImage(direction, x, y,
-          shared_widget_info,
-          std::shared_ptr<ImageFile>(new ImageFile(fd, size))));
+          shared_widget_info, std::move(image_file)));
     listener_->OnPrepareEvent(raw_image_, serial);
   } else {
     _W("Unknown type(%u)", type);
@@ -120,6 +119,8 @@ void LauncherService::Impl::OnPrepareEvent(uint32_t target_type,
     int32_t y,
     const std::string& shared_widget_info,
     uint32_t serial) {
+  _W("target_type(%u), direction(%d), serial(%u)",
+      target_type, static_cast<int>(direction), serial);
   if (target_type == TZSH_LAUNCHER_SERVICE_TARGET_TYPE_REMOTE_SURFACE) {
     done_ = false;
     listener_->OnResetEvent(serial);
@@ -144,6 +145,7 @@ void LauncherService::Impl::OnPrepareEvent(uint32_t target_type,
 }
 
 void LauncherService::Impl::OnStopEvent(uint32_t serial) {
+  _W("serial(%u)", serial);
   listener_->OnStopEvent(serial);
   listener_->OnResetEvent(serial);
   raw_image_.reset();
@@ -151,6 +153,7 @@ void LauncherService::Impl::OnStopEvent(uint32_t serial) {
 }
 
 void LauncherService::Impl::OnErrorEvent(Error error, uint32_t serial) {
+  _W("error(%d), serial(%u)", static_cast<int>(error), serial);
   if (error == Error::None)
     return;
 
@@ -164,6 +167,7 @@ void LauncherService::Impl::OnErrorEvent(Error error, uint32_t serial) {
 }
 
 void LauncherService::Impl::OnCleanupEvent(uint32_t serial) {
+  _W("serial(%u)", serial);
   listener_->OnCleanUpEvent(serial);
 }