Attempt to populate `.ext_attr` crashes application


I try to adopt patterns from “settings menu” demo to my need. Problem is, when i try to populate ext_attr of page (list) items, application crashes immediately after start, without any message.

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

Platformio, Ubuntu 18.04.LTS

What do you want to achieve?

I’d like attach metadata to UI controls, to distinguish between list elements. I guess, this can be done via User Data, but settings demo from lv_apps uses uses `ext_attr and i try to repeat that approach.

What have you tried so far?

Code to reproduce

See link at start. Project is working, just open in PIO and select emulator build. Controls - kbd arrows + enter.

Screenshot and/or video

menu_dose_item_ext_t needs to contain the ext_attr to extend as first parameter.
Take a look at the lv_btn_ext_t. It contains lv_cont_ext as first field.

This way lv_cont will see it’s lv_cont_ext_t data by looking at the ext_attr pointer but lv_btn will see more.

1 Like

Ah! That extension already exists with default data, and idea is to replace it with bigger memory block with the same head? So it will continue work with previous code and leave me some room in tail. Right?

Correct. lv_obj_allocate_ext_attr will automatically reallocate the buffer (if it already exists) keeping the same contents at the beginning.

1 Like