From ccac3a7bfe32f17c00b7342529b23063e36775ad Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Wed, 17 Feb 2021 14:47:48 +0900 Subject: Move unsubscribe_dbus_signal position to reset signal_id Change-Id: I4a24e443ff5f1c07d8ccf178f212bbc1efcb0d42 Signed-off-by: lokilee73 --- hw/battery/battery.c | 5 +++-- hw/external_connection/external_connection.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/battery/battery.c b/hw/battery/battery.c index d3b3ca6..ce4d76a 100644 --- a/hw/battery/battery.c +++ b/hw/battery/battery.c @@ -150,9 +150,10 @@ static int battery_register_changed_event( static void battery_unregister_changed_event( BatteryUpdated updated_cb) { - unsubscribe_dbus_signal(NULL, signal_id); - if (signal_id > 0) + if (signal_id > 0) { + unsubscribe_dbus_signal(NULL, signal_id); signal_id = 0; + } sdata.updated_cb = NULL; sdata.data = NULL; } diff --git a/hw/external_connection/external_connection.c b/hw/external_connection/external_connection.c index aca4ac2..5cd129b 100644 --- a/hw/external_connection/external_connection.c +++ b/hw/external_connection/external_connection.c @@ -138,9 +138,10 @@ static int external_connection_register_changed_event( static void external_connection_unregister_changed_event( ConnectionUpdated updated_cb) { - unsubscribe_dbus_signal(NULL, signal_id); - if (signal_id > 0) + if (signal_id > 0) { + unsubscribe_dbus_signal(NULL, signal_id); signal_id = 0; + } sdata.updated_cb = NULL; sdata.data = NULL; } -- cgit v1.2.3