How to remove window without crashing


I have created a window without close button, the window is created correctly, but I have noticed that if I want to remove the window programatically, it causes a crash, I have tried both:
lv_obj_del and lv_obj_del_async, the first one seems to close the window but immediately afterwards it crashes, the async method, just leave the window opnened without being responsive

What MCU/Processor/Board and compiler are you using?

ESP32 4MB PSRAM, 16MG Flash

What LVGL version are you using?


What do you want to achieve?

I would like to close a window object programatically without crashing

What have you tried so far?

I have use both async and not async methods to delete the window object

Code to reproduce

The code block(s) should be formatted like:

lv_obj_t * win_req;
void password_req_win(void){
  unlockTimer = millis();
  win_req = lv_win_create(lv_scr_act(), NULL);
  lv_win_set_title(win_req, "Unlock"); 

  cont = lv_cont_create(win_req, NULL);
  lv_obj_set_auto_realign(cont, true);                    /*Auto realign when the size changes*/
  lv_obj_align_origo(cont, NULL, LV_ALIGN_CENTER, 0,0);  /*This parametrs will be sued when realigned*/
  lv_cont_set_fit(cont, LV_FIT_TIGHT);
  lv_cont_set_layout(cont, LV_LAYOUT_COLUMN_MID);

  lv_obj_t * oneline_ta = lv_textarea_create(cont, NULL);
  lv_textarea_set_pwd_mode(oneline_ta, false);
  lv_textarea_set_one_line(oneline_ta, true);
  lv_textarea_set_cursor_hidden(oneline_ta, false);
  lv_textarea_set_cursor_blink_time(oneline_ta, 500);
  lv_textarea_set_text(oneline_ta, "");
  lv_obj_set_event_cb(oneline_ta, ta_event_unlock_cb);

  lv_obj_set_size(oneline_ta,140, 35);

void loop()
  if( (millis() - unlockTimer) > 7000 && unlockTimer != 0){
    windowOpened = false;
    if (kbOpened == true) {
        lv_keyboard_set_textarea(kb, NULL); /*De-assign the text area  to hide it cursor if needed*/
        kbOpened = false;
    lv_obj_del(win_req); // removing the window here

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

Nevermind, it was a problem controlling when to stop to delete the window

@beckmx I don’t understand the solutions to resolve the problem, Can you explain my? I have a similar problem?


As you can see there is a loop in there, obviusly the loop is repeating all the time, in my case I added a timer to delete the window after 7 seconds, but I never put in there if there was no window anymore, so, the first time it deletes the window, then in the next loop it tries to delete but obviusly it doesnt exist anymore and crashes, I just added a control var to know when it was already removed