At the beginning, I created some objects (such as img, label, cont, etc.) and applied some styles and image resources. In some cases, I need to delete these objects and reload other objects and image resources. However, after two consecutive successes, it crashes in the function lv_style_property_t get_style_prop(const lv_style_t * style, size_t idx).
What MCU/Processor/Board and compiler are you using?
What LVGL version are you using?
What do you want to achieve?
I want to delete these objects and reload other objects and image resources, and keep repeating this process.
What have you tried so far?
I tried to clean up the style list of all objects (including child objects), and then use lv_obj_del() to delete the parent object, but it didn’t improve.
Code to reproduce
Sorry for some reasons, it is not convenient to paste the code.
I want to know what I need to pay attention to if I implement this function (repeatedly create and delete objects, and load different styles and image resources). This is my first time using lvgl, thank you very much!
Without reproducible code it will be difficult to tell you anything specific, however, I’d check that your lv_style_t variables are not going out of scope/getting deallocated before the object finishes getting deleted.
Part of the code is like this:
lv_style_set_bg_opa(&m_Style, LV_STATE_DEFAULT, LV_OPA_0);
lv_style_set_text_font(&m_Style, LV_STATE_DEFAULT, &font_source_han_sans_cn_regular_28);
lv_style_set_text_color(&m_Style, LV_STATE_DEFAULT, lv_color_make(0x9b, 0x9b, 0xa1));