From de044e25f758d66df78755bcd364eed62bcb69bc Mon Sep 17 00:00:00 2001 From: Simo Piiroinen Date: Wed, 6 Jul 2016 16:11:30 +0300 Subject: [PATCH] [usb_moded] Make sure charging timeout timer ids are not leaked If charging_timeout should already contain a valid timer id when the timer is started, the old timer will be leaked. Remove existing timer id before assigning new one. Signed-off-by: Simo Piiroinen --- src/usb_moded.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/usb_moded.c b/src/usb_moded.c index 674cc2c..44f85bb 100644 --- a/src/usb_moded.c +++ b/src/usb_moded.c @@ -294,6 +294,8 @@ void set_usb_connected_state(void) */ usb_moded_send_signal(USB_CONNECTED_DIALOG_SHOW); /* fallback to charging mode after 3 seconds */ + if( charging_timeout ) + g_source_remove(charging_timeout); charging_timeout = g_timeout_add_seconds(3, charging_fallback, NULL); /* in case there was nobody listening for the UI, they will know that the UI is needed by requesting the current mode */