Fix pkgmgr client is not cleared bug 30/206030/2
authorhyunho <hhstark.kang@samsung.com>
Mon, 13 May 2019 10:11:19 +0000 (19:11 +0900)
committerhyunho <hhstark.kang@samsung.com>
Tue, 14 May 2019 00:57:56 +0000 (09:57 +0900)
Change-Id: I1e76ef0ae82488b419d2c0cb931d1c16a1a959f3
Signed-off-by: hyunho <hhstark.kang@samsung.com>
watchface-complication/complication-connector.cc

index e434bda..2a7e0f4 100644 (file)
@@ -61,7 +61,7 @@ ComplicationConnector::Impl::Impl() = default;
 bool ComplicationConnector::EmitSignal(IGDBus::SigType type,
     std::string target_id, std::string id, int sub_id, std::string cmd,
     GVariant* data) {
-  GError* err = NULL;
+  GError* err = nullptr;
   gboolean result = TRUE;
   std::string path = util::EncodeStr(
       type == IGDBus::Complication ?
@@ -71,16 +71,16 @@ bool ComplicationConnector::EmitSignal(IGDBus::SigType type,
 
   LOGI("emit : %s, %s, %d, %s", target_id.c_str(), id.c_str(), sub_id,
                                 cmd.c_str());
-  LOGI("emit signal %s, %s", name.empty() ? NULL : name.c_str(), path.c_str());
+  LOGI("emit signal %s, %s", name.empty() ? nullptr : name.c_str(), path.c_str());
   result = g_dbus_connection_emit_signal(
             impl_->conn_,
-            name.empty() ? NULL : name.c_str(),
+            name.empty() ? nullptr : name.c_str(),
             path.c_str(),
             COMPLICATION_INTERFACE,
             cmd.c_str(), data, &err);
   if (result == FALSE) {
     LOGE("g_dbus_connection_emit_signal() is failed");
-    if (err != NULL) {
+    if (err != nullptr) {
       LOGE("g_dbus_connection_emit_signal() err : %s",
           err->message);
       g_error_free(err);
@@ -105,17 +105,18 @@ IPackageManager* ComplicationConnector::CreatePackageManager(bool mock) {
 }
 
 void ComplicationConnector::WatchPackageEvent(IPackageManager::IPackageEvent* pe) {
-  if (impl_->pkgmgr_client_ == NULL) {
+  if (impl_->pkgmgr_client_ == nullptr) {
     impl_->pkgmgr_client_ = pkgmgr_client_new(PC_LISTENING);
-    if (impl_->pkgmgr_client_ == NULL) {
+    if (impl_->pkgmgr_client_ == nullptr) {
       LOGE("fail to create pkgmgr client");
       return;
     }
 
     if (pkgmgr_client_listen_status(impl_->pkgmgr_client_ ,
-        impl_->PkgmgrPackageStatusCb, NULL) <= 0) {
+        impl_->PkgmgrPackageStatusCb, nullptr) <= 0) {
       LOGE("fail to listen pkg status");
       pkgmgr_client_free(impl_->pkgmgr_client_);
+      impl_->pkgmgr_client_ = nullptr;
       return;
     }
     LOGI("listen pkg status");
@@ -127,12 +128,12 @@ void ComplicationConnector::UnWatchPackageEvent(IPackageManager::IPackageEvent*
   impl_->package_listener_list_.remove(pe);
   if (impl_->package_listener_list_.size() == 0) {
     pkgmgr_client_free(impl_->pkgmgr_client_);
-    impl_->pkgmgr_client_ = NULL;
+    impl_->pkgmgr_client_ = nullptr;
   }
 }
 
 int ComplicationConnector::Init() {
-  GError* error = NULL;
+  GError* error = nullptr;
   std::string encoded_name;
   int owner_id;
   std::unique_ptr<Impl> tmp_impl;
@@ -144,9 +145,9 @@ int ComplicationConnector::Init() {
     return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
   }
 
-  tmp_impl->conn_ = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
-  if (tmp_impl->conn_ == NULL) {
-    if (error != NULL) {
+  tmp_impl->conn_ = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, &error);
+  if (tmp_impl->conn_ == nullptr) {
+    if (error != nullptr) {
       LOGE("Failed to get dbus [%s]", error->message);
       g_error_free(error);
     }
@@ -154,7 +155,7 @@ int ComplicationConnector::Init() {
   }
 
   tmp_impl->pkgmgr_client_ = pkgmgr_client_new(PC_LISTENING);
-  if (tmp_impl->pkgmgr_client_ == NULL) {
+  if (tmp_impl->pkgmgr_client_ == nullptr) {
     LOGE("fail to create pkgmgr client");
     return WATCHFACE_COMPLICATION_ERROR_IO_ERROR;
   }
@@ -169,7 +170,7 @@ int ComplicationConnector::Init() {
   LOGI("own name %s", encoded_name.c_str());
   owner_id = g_bus_own_name_on_connection(tmp_impl->conn_, encoded_name.c_str(),
                                           G_BUS_NAME_OWNER_FLAGS_NONE,
-                                          NULL, NULL, NULL, NULL);
+                                          nullptr, nullptr, nullptr, nullptr);
   if (!owner_id) {
     g_object_unref(tmp_impl->conn_);
     LOGE("g_bus_own_name_on_connection, error");