From 89e1620883df64692685265c922b9961bb9c54cd Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 31 Jan 2024 01:32:57 +0300 Subject: [PATCH] rename timers, stop before free --- applications/main/lfrfid/scenes/lfrfid_scene_emulate.c | 10 ++++++---- applications/main/nfc/scenes/nfc_scene_emulate.c | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c b/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c index 59fbb54d6..b729f4de0 100644 --- a/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c +++ b/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c @@ -2,7 +2,7 @@ #define LFRFID_EMULATION_TIME_MAX_MS (5 * 60 * 1000) -FuriTimer* timer; +FuriTimer* timer_auto_exit; void lfrfid_scene_emulate_popup_callback(void* context) { LfRfid* app = context; @@ -31,8 +31,9 @@ void lfrfid_scene_emulate_on_enter(void* context) { lfrfid_worker_emulate_start(app->lfworker, (LFRFIDProtocol)app->protocol_id); notification_message(app->notifications, &sequence_blink_start_magenta); - timer = furi_timer_alloc(lfrfid_scene_emulate_popup_callback, FuriTimerTypeOnce, app); - furi_timer_start(timer, LFRFID_EMULATION_TIME_MAX_MS); + timer_auto_exit = + furi_timer_alloc(lfrfid_scene_emulate_popup_callback, FuriTimerTypeOnce, app); + furi_timer_start(timer_auto_exit, LFRFID_EMULATION_TIME_MAX_MS); view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup); } @@ -59,7 +60,8 @@ bool lfrfid_scene_emulate_on_event(void* context, SceneManagerEvent event) { void lfrfid_scene_emulate_on_exit(void* context) { LfRfid* app = context; - furi_timer_free(timer); + furi_timer_stop(timer_auto_exit); + furi_timer_free(timer_auto_exit); notification_message(app->notifications, &sequence_blink_stop); popup_reset(app->popup); diff --git a/applications/main/nfc/scenes/nfc_scene_emulate.c b/applications/main/nfc/scenes/nfc_scene_emulate.c index 60be11a62..0f178f463 100644 --- a/applications/main/nfc/scenes/nfc_scene_emulate.c +++ b/applications/main/nfc/scenes/nfc_scene_emulate.c @@ -4,7 +4,7 @@ #define NFC_EMULATION_TIME_MAX_MS (5 * 60 * 1000) -FuriTimer* timer; +FuriTimer* timer_auto_exit; void nfc_scene_emulate_timer_callback(void* context) { NfcApp* instance = context; @@ -18,8 +18,9 @@ void nfc_scene_emulate_on_enter(void* context) { nfc_protocol_support_on_enter(NfcProtocolSupportSceneEmulate, context); - timer = furi_timer_alloc(nfc_scene_emulate_timer_callback, FuriTimerTypeOnce, instance); - furi_timer_start(timer, NFC_EMULATION_TIME_MAX_MS); + timer_auto_exit = + furi_timer_alloc(nfc_scene_emulate_timer_callback, FuriTimerTypeOnce, instance); + furi_timer_start(timer_auto_exit, NFC_EMULATION_TIME_MAX_MS); } bool nfc_scene_emulate_on_event(void* context, SceneManagerEvent event) { @@ -40,6 +41,7 @@ bool nfc_scene_emulate_on_event(void* context, SceneManagerEvent event) { } void nfc_scene_emulate_on_exit(void* context) { - furi_timer_free(timer); + furi_timer_stop(timer_auto_exit); + furi_timer_free(timer_auto_exit); nfc_protocol_support_on_exit(NfcProtocolSupportSceneEmulate, context); }