Help With Extended Data in LVGL [SOLVED]

Hello everyone,

I am trying to create objects that mirror the goals on the Change Up field. I am using extended data to assist me with this.

First, I create a new struct.

typedef struct {
  lv_imgbtn_ext_t tower;
  std::vector<char> balls;
  bool disabled = false;
} tower_t;

Then, I define an array of nine pointers to tower_t.

tower_t * towers[9];

I also create an array of nine lv_obj_t *, which corresponds to the actual objects displayed on the screen.

lv_obj_t * towers_obj[9];

I then create a for-loop to iterate through this array and set/get the extended data.

  for(int i = 0; i < std::size(towers); i++){
    lv_obj_allocate_ext_attr(towers_obj[i], sizeof(tower_t));
    towers[i] = (tower_t*) lv_obj_get_ext_attr(towers_obj[i]);
  }

Finally, I assign a vector to towers[0]->balls.

towers[0]->balls = {'r', 'b'};

The problem is, after assigning the vector to towers[0]->balls, the program freezes. Any idea why?

EDIT: I solved the issue. Just don’t use extended data.