Skip to content

Commit 1b79721

Browse files
committed
main: fix segfault because of lv_task_handler() concurrently called
Both InfiniSim/main.cpp and SystemTask.cpp periodically called `lv_task_handler()`. This introduces a race condition, which leads to a segmentation fault in either the main or the SystemTasks call of `lv_task_handler()`. Now `main` only calls the `lv_task_handler()` if the `SystemTask` does not (while the screen is turned off). We need this for the Simulator, otherwise the "Screen is OFF" message won't appear, and the right mouse button won't be recognized to wake up the simulated screen. Fixes: #3
1 parent db3144c commit 1b79721

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

main.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,11 @@ class Framework {
630630
lv_label_set_text_static(screen_off_label, "Screen is OFF");
631631
lv_obj_align(screen_off_label, nullptr, LV_ALIGN_CENTER, 0, -20);
632632
}
633+
/* Periodically call the lv_task handler.
634+
* It could be done in a timer interrupt or an OS task too.*/
635+
// only call the task handler if the screen is off,
636+
// when the screen is enabled the call is done in the SystemTask class
637+
lv_task_handler();
633638
} else {
634639
if (screen_off_created) {
635640
screen_off_created = false;
@@ -722,9 +727,6 @@ int main(int argc, char **argv)
722727
Framework fw(fw_status_window_visible, 240,240);
723728

724729
while(1) {
725-
/* Periodically call the lv_task handler.
726-
* It could be done in a timer interrupt or an OS task too.*/
727-
lv_task_handler();
728730
fw.handle_keys(); // key event polling
729731
fw.handle_touch_and_button();
730732
fw.refresh();

0 commit comments

Comments
 (0)