From eee44dac60a5180ed9598fbc069d8643742574cb Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 29 Oct 2020 11:47:36 +0900 Subject: [PATCH] Fix EmitSignal() method This patch adds g_dbus_connection_flush_sync() call. Change-Id: If2b0f053c0042cb33cabd981907cc6c887921d67 Signed-off-by: Hwankyu Jhun --- notification-ex/dbus_sender.cc | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/notification-ex/dbus_sender.cc b/notification-ex/dbus_sender.cc index ba0d8f9..202a072 100644 --- a/notification-ex/dbus_sender.cc +++ b/notification-ex/dbus_sender.cc @@ -55,27 +55,31 @@ DBusSender::~DBusSender() { bool DBusSender::Impl::EmitSignal(string bus_name, string signal_name, GVariant* data) { - GError* err = NULL; - gboolean result = TRUE; - - result = g_dbus_connection_emit_signal( - DBusConnectionManager::GetInst().GetConnection(), - bus_name.empty() ? NULL : bus_name.c_str(), - path_.c_str(), - DBusConnectionManager::GetInst().GetInterfaceName().c_str(), - signal_name.c_str(), data, &err); + GError* err = nullptr; + GDBusConnection* conn = DBusConnectionManager::GetInst().GetConnection(); + gboolean result = g_dbus_connection_emit_signal(conn, + bus_name.empty() ? NULL : bus_name.c_str(), + path_.c_str(), + DBusConnectionManager::GetInst().GetInterfaceName().c_str(), + signal_name.c_str(), data, &err); if (result == FALSE) { - LOGE("g_dbus_connection_emit_signal() is failed"); - if (err != NULL) { - LOGE("g_dbus_connection_emit_signal() err : %s", - err->message); - g_error_free(err); - } - } else { - LOGI("Successfully emit signal to %s, %s, %s", - bus_name.c_str(), path_.c_str(), signal_name.c_str()); + LOGE("g_dbus_connection_emit_signal() is failed. error(%s)", + err ? err->message : "Unknown"); + g_clear_error(&err); + return false; } - return result; + + result = g_dbus_connection_flush_sync(conn, NULL, &err); + if (result == FALSE) { + LOGE("g_dbus_connection_flush_sync() is failed. error(%s)", + err ? err->message : "Unknown"); + g_clear_error(&err); + return false; + } + + LOGI("Successfully emit signal to %s, %s, %s", + bus_name.c_str(), path_.c_str(), signal_name.c_str()); + return true; } string DBusSender::Impl::GetBusName(string appid, string dest_appid) const { -- 2.7.4