From 41b5d5f5c9770430c38e47a2e1684f0a365d7929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=81=8F?= Date: Thu, 2 Dec 2021 01:13:21 +0300 Subject: [PATCH] Gui: fix random crashes under load in icon_animation (#859) --- applications/gui/icon_animation.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/applications/gui/icon_animation.c b/applications/gui/icon_animation.c index 842798ec..530f3fa7 100644 --- a/applications/gui/icon_animation.c +++ b/applications/gui/icon_animation.c @@ -13,6 +13,8 @@ IconAnimation* icon_animation_alloc(const Icon* icon) { void icon_animation_free(IconAnimation* instance) { furi_assert(instance); + icon_animation_stop(instance); + while(xTimerIsTimerActive(instance->timer) == pdTRUE) osDelay(1); furi_check(osTimerDelete(instance->timer) == osOK); free(instance); } @@ -65,8 +67,9 @@ void icon_animation_start(IconAnimation* instance) { furi_assert(instance->icon->frame_rate); furi_check( xTimerChangePeriod( - instance->timer, (osKernelGetTickFreq() / instance->icon->frame_rate), 0) == - pdPASS); + instance->timer, + (osKernelGetTickFreq() / instance->icon->frame_rate), + portMAX_DELAY) == pdPASS); } } @@ -74,7 +77,7 @@ void icon_animation_stop(IconAnimation* instance) { furi_assert(instance); if(instance->animating) { instance->animating = false; - furi_check(xTimerStop(instance->timer, 0) == pdPASS); + furi_check(xTimerStop(instance->timer, portMAX_DELAY) == pdPASS); instance->frame = 0; } }