Disconnect the monitor connection when callback unregister 13/97913/1
authorMyungki Lee <mk5004.lee@samsung.com>
Tue, 15 Nov 2016 09:25:59 +0000 (18:25 +0900)
committerMyungki Lee <mk5004.lee@samsung.com>
Tue, 15 Nov 2016 09:33:36 +0000 (18:33 +0900)
Change-Id: I1a25f04433ec688038c0c176082b92fcf645ddb0
Signed-off-by: Myungki Lee <mk5004.lee@samsung.com>
lib/src/shortcut_internal.c

index 26bd565..d8f4238 100755 (executable)
@@ -429,6 +429,25 @@ static void _on_name_vanished(GDBusConnection *connection,
 }
 /* LCOV_EXCL_STOP */
 
+void _ipc_monitor_fini(void)
+{
+       if (provider_monitor_id) {
+               g_bus_unwatch_name(provider_monitor_id);
+               provider_monitor_id = 0;
+       }
+
+       if (monitor_id) {
+               g_dbus_connection_signal_unsubscribe(_gdbus_conn, monitor_id);
+               monitor_id = 0;
+       }
+
+       if (_gdbus_conn) {
+               g_object_unref(_gdbus_conn);
+               _gdbus_conn = NULL;
+       }
+
+}
+
 void _set_request_cb(shortcut_request_cb request_cb, void *data)
 {
        _request_callback_info.request_cb = request_cb;
@@ -437,6 +456,10 @@ void _set_request_cb(shortcut_request_cb request_cb, void *data)
 
 void _unset_request_cb(void)
 {
+       if (_remove_callback_info.remove_cb == NULL &&
+               _remove_callback_info.data == NULL)
+               _ipc_monitor_fini();
+
        _request_callback_info.request_cb = NULL;
        _request_callback_info.data = NULL;
 }
@@ -449,6 +472,10 @@ void _set_remove_cb(shortcut_remove_cb remove_cb, void *data)
 
 void _unset_remove_cb(void)
 {
+       if (_request_callback_info.request_cb == NULL &&
+               _request_callback_info.data == NULL)
+               _ipc_monitor_fini();
+
        _remove_callback_info.remove_cb = NULL;
        _remove_callback_info.data = NULL;
 }