Add missing memory management codes 36/229736/2
authorhyunho <hhstark.kang@samsung.com>
Fri, 3 Apr 2020 06:33:32 +0000 (15:33 +0900)
committerhyunho <hhstark.kang@samsung.com>
Fri, 3 Apr 2020 06:46:14 +0000 (15:46 +0900)
Change-Id: Ia5da1b706de6bc1a5ce92cbbc6e823cffc0622b2
Signed-off-by: hyunho <hhstark.kang@samsung.com>
ambient-viewer/src/ambient-viewer.cc
watch-holder/api/watch_holder.cc
watch-holder/api/watch_mirror.cc
watch-holder/src/ambient_listener.cc
watch-holder/src/watch_holder.cc
watch-holder/src/watch_mirror.cc

index a086dc91e61a1ce393a03d99c68926c24a6e3374..86f058b01902a21e3f4bd5a932b9830782ab1573 100644 (file)
@@ -48,7 +48,10 @@ AmbientViewer::AmbientViewer(Evas_Object* win)
   LOGD("CREATE AMBIENT VIEWER");
 }
 
-AmbientViewer::~AmbientViewer() = default;
+AmbientViewer::~AmbientViewer() {
+  if (receive_signal_conn_)
+    aul_app_com_leave(receive_signal_conn_);
+}
 
 string AmbientViewer::GetUUID(string rid) const {
   char uuid[37];
index a4b841c052c0487166049d772c0ff78349a85a2c..5585262bd13dd68edc54e15f770a2cda7cab6172 100644 (file)
@@ -109,6 +109,9 @@ C_EXPORT int watch_holder_get_current(watch_holder_h handle, watch_h *watch) {
   if (handle == nullptr)
     return WATCH_HOLDER_ERROR_INVALID_PARAMETER;
 
+  if (handle->GetCurrent() == nullptr)
+    return WATCH_HOLDER_ERROR_INVALID_OPERATION;
+
   *watch = reinterpret_cast<watch_h>(handle->GetCurrent().get());
 
   return WATCH_HOLDER_ERROR_NONE;
index 1daf29fd2e5a9e8f656185d6609c0a175f0906c9..b3996c63f1662ec4373d9cfaf152cca2fce992ec 100644 (file)
@@ -102,6 +102,9 @@ C_EXPORT int watch_mirror_get_current(watch_mirror_h handle, sharable_watch_h *w
   if (handle == nullptr)
     return WATCH_HOLDER_ERROR_INVALID_PARAMETER;
 
+  if (handle->GetCurrent() == nullptr)
+    return WATCH_HOLDER_ERROR_INVALID_OPERATION;
+
   *watch = reinterpret_cast<sharable_watch_h>(handle->GetCurrent().get());
 
   return WATCH_HOLDER_ERROR_NONE;
index c69dd4d9010f3fe0dfea722e4ca87db55bede3e5..07dedb38dcfc522ca16b9bd1a51ae414a88b7e3a 100644 (file)
@@ -49,8 +49,15 @@ namespace watch_holder {
       bundle* envelope, void* user_data) {
     LOGI("Receive aod ambient event");
     AmbientListener* listener = (AmbientListener*)user_data;
-    tizen_base::Bundle b = tizen_base::Bundle(envelope, false, false);
+
+    if (!envelope) {
+      LOGE("Bad bundle data from application");
+      return -1;
+    }
+
+    tizen_base::Bundle b = tizen_base::Bundle(envelope, true, true);
     std::string event_type= b.GetString("__APP_AMBIENT_EVENT__");
+    LOGI("event type (%s)", event_type.c_str());
     int type = stoi(event_type);
     std::string sender = b.GetString("__APP_AMBIENT_SENDER__");
     b.Delete("__APP_AMBIENT_EVENT__");
@@ -88,5 +95,8 @@ namespace watch_holder {
   AmbientListener::~AmbientListener() {
     if (ambient_changed_signal_conn_)
       aul_app_com_leave(ambient_changed_signal_conn_);
+
+    if (ambient_event_signal_conn_)
+      aul_app_com_leave(ambient_event_signal_conn_);
   }
 }
index 391a1db91b7c72c6f93d526d04334c69d6e4e9e2..63e65128540a0e563f92b0fc1bd163a6b568f5df 100644 (file)
@@ -97,6 +97,10 @@ const std::list<std::shared_ptr<Watch>>& WatchHolder::GetStack() const {
 }
 
 std::shared_ptr<Watch> WatchHolder::GetCurrent() const {
+  if (stack_.empty()) {
+    LOGW("Empty stack!");
+    return nullptr;
+  }
   return stack_.back();
 }
 
index 3ef821881937c492fac1714f8432dd026eb1a2f6..0c4df0b4fb9b2239700d5ed5fbe26ca751748302 100644 (file)
@@ -80,6 +80,10 @@ int WatchMirror::Listen() {
 }
 
 std::shared_ptr<ISharableWatch> WatchMirror::GetCurrent() const {
+  if (stack_.empty()) {
+    LOGW("Empty stack!");
+    return nullptr;
+  }
   return stack_.back();
 }