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

@@ -44,6 +44,7 @@
- UL: Fix clipper date timestamp (by @luu176)
- BadKB: Fix key combos main keys being case sensitive (by @WillyJL)
- Sub-GHz:
- Fix freqquency analyzer deadlock when holding Ok (by @WillyJL)
- UL: Fix CAME 24bit decoder (by @xMasterX)
- UL: Tune holtek ht12x to decode holtek only and not conflict with came 12bit (by @xMasterX)
- UL: Fix Rename scene bug, that was replacing file name with random name when Rename is opened then closed then opened again (by @xMasterX)

View File

@@ -72,6 +72,7 @@ bool subghz_scene_frequency_analyzer_on_event(void* context, SceneManagerEvent e
// Don't need to save, we already saved on short event (and on exit event too)
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateIDLE);
scene_manager_set_scene_state(subghz->scene_manager, SubGhzSceneStart, 10);
scene_manager_previous_scene(subghz->scene_manager); // Stops the worker
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiver);
return true;
}

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);
}
}