Sub-GHz: Fix freq analyzer deadlock by holding Ok

Was more reproducible when using FM238 modulation, by stopping the
worker thread in the input callback the system GUI thread was deadlocked
when switching scenes if the timing was just right; this should be
handled by app thread.
This commit is contained in:
WillyJL
2025-06-22 03:04:03 +01:00
parent 19595823f2
commit 45cf599281
3 changed files with 8 additions and 9 deletions

View File

@@ -255,9 +255,9 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) {
need_redraw = true;
}
} else if(
(event->type != InputTypeRelease && event->type != InputTypeRepeat) &&
(event->type == InputTypeShort || event->type == InputTypeLong) &&
event->key == InputKeyOk) {
need_redraw = true;
need_redraw = false;
bool updated = false;
uint32_t frequency_to_save;
with_view_model(
@@ -286,22 +286,19 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) {
instance->worker, frequency_candidate);
if(frequency_candidate > 0 && frequency_candidate != model->frequency_to_save) {
model->frequency_to_save = frequency_candidate;
frequency_to_save = frequency_candidate;
updated = true;
}
},
true);
false);
if(updated) {
instance->callback(SubGhzCustomEventViewFreqAnalOkShort, instance->context);
}
// First the device receives short, then when user release button we get long
// If it was a long press also send a second event
if(event->type == InputTypeLong && frequency_to_save > 0) {
// Stop worker
if(subghz_frequency_analyzer_worker_is_running(instance->worker)) {
subghz_frequency_analyzer_worker_stop(instance->worker);
}
// Worker stopped on app thread instead of GUI thread when switching scene in callback
instance->callback(SubGhzCustomEventViewFreqAnalOkLong, instance->context);
}
}