libaurum: add an exception handling logic
authorWonki Kim <wonki_.kim@samsung.com>
Fri, 14 Aug 2020 05:47:25 +0000 (14:47 +0900)
committerJongmin Lee <jm105.lee@samsung.com>
Thu, 27 Aug 2020 05:00:13 +0000 (14:00 +0900)
there is a lack of exception handling logic in screenshot capturing feature. this patch improves it.

Change-Id: Icedfbc1c028d75c6ef04cf4b8c80bc67b93f7c73

libaurum/src/Impl/TizenDeviceImpl.cc

index a6d9006b11c5a3bd1de8c44c5150805d233fefbe..4ccba576054ef0cb55416d883933690fbc005ada 100644 (file)
@@ -284,21 +284,25 @@ bool TizenDeviceImpl::takeScreenshot(std::string path, float scale, int quality)
     efl_util_screenshot_h screenshot = NULL;
     tbm_surface_h tbm_surface = NULL;
 
-    int width, height;
-    system_info_get_platform_int("http://tizen.org/feature/screen.width", &width);
-    system_info_get_platform_int("http://tizen.org/feature/screen.height", &height);
+    int width = 0, height = 0;
+    if (system_info_get_platform_int("http://tizen.org/feature/screen.width", &width) ||
+        system_info_get_platform_int("http://tizen.org/feature/screen.height", &height))
+        return false;
 
     screenshot = efl_util_screenshot_initialize(width, height);
 
     if (screenshot) {
         tbm_surface = efl_util_screenshot_take_tbm_surface(screenshot);
         if (tbm_surface) {
-            char path_cstr[PATH_MAX];
-            strcpy(path_cstr, path.c_str());
-            tdm_helper_dump_buffer(tbm_surface, path_cstr);
+            tdm_helper_dump_buffer(tbm_surface, path.c_str());
             sync();
+        } else {
+            efl_util_screenshot_deinitialize(screenshot);
+            return false;
         }
         efl_util_screenshot_deinitialize(screenshot);
+    } else {
+        return false;
     }
 
     return true;