Description
hi, I have sometimes crash with _lv_event_mark_deleted
when call lv_msgbox_close(lv_obj_t * msg)
method.
What MCU/Processor/Board and compiler are you using?
ESP32-S3, PlatformIO
What LVGL version are you using?
LVGL version 8.3
What do you want to achieve?
I want to output errors from the queue in the form of msgbox with error information, but I have problems closing the msgbox.
What have you tried so far?
1.I’m tried replace lv_msgbox_close
to lv_msgbox_close_async
, but this not give result.
2. tried set mutex for lv_task_handler()
;
xGuiSemaphore = xSemaphoreCreateMutex();
void uiTask(void * ){
draw.init();
while(1){
xSemaphoreTake(xGuiSemaphore, portMAX_DELAY);
lv_task_handler();
xSemaphoreGive(xGuiSemaphore);
vTaskDelay(pdMS_TO_TICKS(10));
}
}
- tried using mutex on closing msgbox with mutex in
void uiTask(void * )
, but with this it is impossible to close the tab
xSemaphoreTake(xGuiSemaphore, portMAX_DELAY);
lv_msgbox_close(msgbox);
xSemaphoreGive(xGuiSemaphore);
4.tried check obj with lv_obj_is_valid
before call lv_msgbox_close/lv_msgbox_close_async
Code to reproduce
The application must work with a touch screen and keyboard, and used commands for focus work.
EventGroupHandle_t errors_event;
static void msgbox_handler(lv_event_t * e){
lv_group_focus_freeze(btn_group, false);
if(on_msg == 1){ // current main tab on screen,
lv_group_focus_obj(exitBtn);
lv_indev_set_group(keyboard_indev, main_menu_group);
on_msg = 0; //unlock frequency convertors control
lv_tabview_set_act(tv, 0, LV_ANIM_OFF);
}else{ // if view menu focus to last element
lv_group_focus_obj(focused);
}
lv_msgbox_close(msgbox);
xEventGroupSetBits(errors_event, NEXT); // allow create next msgbox
}
static bool messagebox_has_closed(){
return xEventGroupWaitBits(errors_event, NEXT, pdTRUE, pdFALSE, portMAX_DELAY) & NEXT;
}
static const char * btns[] = {"OK", ""};
void errorsTask(void *){
while(1){
Error * error;
if(messagebox_has_closed()){
xQueueReceive(errors_queue, &error, portMAX_DELAY);
focused = lv_group_get_focused(btn_group); //remember prev focused object
if(tab_id == 0){ //main page
on_msg = 1; //set lock flag for control frequency convertors
}
lv_indev_set_group(keyboard_indev, btn_group);
msgbox = lv_msgbox_create(NULL, error->getTitle(), error->getDescription(), btns, false);
lv_obj_add_event_cb(msgbox, msgbox_handler, LV_EVENT_CLICKED, NULL);
lv_obj_set_size(msgbox, 350, 300);
lv_obj_center(msgbox);
lv_group_add_obj(btn_group, lv_msgbox_get_btns(msgbox));
lv_group_focus_obj(lv_msgbox_get_btns(msgbox));
lv_obj_add_state(lv_msgbox_get_btns(msgbox), LV_STATE_FOCUS_KEY);
lv_group_focus_freeze(btn_group, true);
}
}
}