diff options
author | Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com> | 2024-03-05 21:49:32 -0300 |
---|---|---|
committer | Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com> | 2024-03-05 21:49:32 -0300 |
commit | b1adbd548eabbf3212e9a53dbb8830d030b15fa7 (patch) | |
tree | 7714ae461474d8c2033de157a211835018eabee2 /movement/movement.c | |
parent | 6ca553e648ff0b4e72520057f1e353759949dcbe (diff) | |
download | Sensor-Watch-b1adbd548eabbf3212e9a53dbb8830d030b15fa7.tar.gz Sensor-Watch-b1adbd548eabbf3212e9a53dbb8830d030b15fa7.tar.bz2 Sensor-Watch-b1adbd548eabbf3212e9a53dbb8830d030b15fa7.zip |
movement: fix unintended timeout short circuiting
Currently, movement drops time out events in case the previous loop
indicates that sleep is not possible due to short circuiting behavior
of logical and in C: if the left-hand side is false, the right hand
side is not evaluated at all, which means the loop is not called.
This was not intended to happen.
Fix it by storing the result in a second boolean variable
and working out the logic after the fact.
Diffstat (limited to 'movement/movement.c')
-rw-r--r-- | movement/movement.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/movement/movement.c b/movement/movement.c index c64df0c0..191429ef 100644 --- a/movement/movement.c +++ b/movement/movement.c @@ -533,7 +533,8 @@ bool app_loop(void) { // first trip | can sleep | cannot sleep | can sleep | cannot sleep // second trip | can sleep | cannot sleep | cannot sleep | can sleep // && | can sleep | cannot sleep | cannot sleep | cannot sleep - can_sleep = can_sleep && wf->loop(event, &movement_state.settings, watch_face_contexts[movement_state.current_face_idx]); + bool can_sleep2 = wf->loop(event, &movement_state.settings, watch_face_contexts[movement_state.current_face_idx]); + can_sleep = can_sleep && can_sleep2; event.event_type = EVENT_NONE; if (movement_state.settings.bit.to_always && movement_state.current_face_idx != 0) { // ...but if the user has "timeout always" set, give it the boot. |