How to delete a complex menu properly?


I can’t delete an complex menu, i tried many things but always get an exception. First tried to delete the parent object but got an exception, then i deleted other objects in the parent but with those object lv_obj_del() works. When i tried to delete only the complex menu i got an exception.

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

ESP-WROOM32 38pins and ILI9488 MCUFRIEND, compiling with arduino-IDE

What LVGL version are you using?


What do you want to achieve?

Delete an complex menu successfully

What have you tried so far?

I tried using lv_obj_del(), lv_obj_del_async and lv_obj_clean(). I even tried to delete all menu’s child objects manually but always the same result: Guru Meditation Error: Core 1 panic’ed (InstrFetchProhibited). Exception was unhandled.

Code to reproduce

static void cfg_event_cb(lv_event_t * e) //this event is called when i press close button
  lv_obj_t * obj = lv_event_get_target(e); //getting the button
  lv_obj_t * bar2 = lv_obj_get_parent(obj); //then i get the 'bar' that contains the button
  lv_obj_t * parent = lv_obj_get_parent(bar2); //this is the 'form' that contains all
  lv_obj_t * bar1 = lv_obj_get_child(parent,1);  //another bar that i want to delete for test
  lv_obj_t * menu = lv_obj_get_child(parent,0); //problematic complex menu
  int hijos=lv_obj_get_child_cnt(menu); //I wanted to know how many child objects menu has
  Serial.printf("Menú tiene %i hijos antes de borrar las páginas\n",hijos); //Result translate to english: "Menu has 3 children before deleting pages"
  lv_obj_t * pagina = lv_obj_get_parent(lv_obj_get_parent(redes)); //'redes' is the name of a list and is contained in an object panel. With this i get the menu page
  lv_obj_t * paginas = lv_obj_get_parent(pagina); //I assumed that the menu had a parent object that contained the pages
  lv_obj_del_async(paginas); //my assumption was correct, and with this delete all the menu pages, but serial monitor says the same: "Menu has 3 children before deleting pages"
  lv_menu_set_sidebar_page(menu,NULL); //according to the documentation, this will clear the side bar and it actually works. Serial monitor shows difference: "Menu has 2 children before deleting pages"
  lv_obj_del_async(bar1); //this command works perfectly
  lv_obj_del_async(bar2); //this command works perfectly
  lv_obj_t * unknown=lv_obj_get_child(menu,1); //I don't know what object is child[0] or child[1]
  lv_obj_del_async(unknown); //when i try to delete the menu's child[0] or child[1] i got an exception and the board reboot. Same if i try delete menu or parent
  Serial.printf("Menú tiene %i hijos despues de borrar las páginas\n",hijos);