mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Fix possible frequency analyzer deadlock when holding Ok
by WillyJL
This commit is contained in:
@@ -71,7 +71,7 @@ bool subghz_scene_frequency_analyzer_on_event(void* context, SceneManagerEvent e
|
||||
} else if(event.event == SubGhzCustomEventViewFreqAnalOkLong) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -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,21 +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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user