Possible Bug using lv_page_get_width_grid

Description

I’m working on my first LVGL application and I need some help! I believe I found a bug following the code below. After a call to lv_page_get_width_grid, I was hitting a hard fault. I started digging and ended up enabling the LVLG_DEBUG flags and now my code asserts with the following message:

Error: lv_page_get_width_fit (lv_page.c #351 lv_page_get_width_fit())
Error: Invalid object (0xB3209F60) (lv_debug.c #127 lv_debug_log_error())

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

RT1062 and Simulator

What LVGL version are you using?

7.11

What do you want to achieve?

What have you tried so far?

Debug and produce minimal code

Code to reproduce

The code block(s) should be formatted like:

void lv_demo_widgets(void)
{
    lv_obj_t *m_tv = lv_scr_act();
    lv_obj_t* rCont = lv_cont_create(m_tv, NULL);
    lv_coord_t grid_w1 = lv_page_get_width_grid(rCont, 2, 1);

    lv_obj_set_width(rCont, grid_w1);
}

I just replaced the simulator lv_demo_widgets with the code above and compiled using the VS Simulator project.

So, I just reduced the code even further, sounds like all I need is to create and container and ask for width.

void lv_demo_widgets(void)
{
    lv_obj_t *m_tv = lv_scr_act();
    lv_obj_t* rCont = lv_cont_create(m_tv, NULL);
    lv_coord_t grid_w1 = lv_page_get_width_grid(rCont, 2, 1);

    lv_obj_set_width(rCont, grid_w1);
}

Result:
Error: lv_page_get_width_fit (lv_page.c #351 lv_page_get_width_fit())
Error: Invalid object (0xE4C49F60) (lv_debug.c #127 lv_debug_log_error())

This is pretty reduced, but my idea was to add some button and checkboxes to this container, and one of my new child objects need to know the width (after padding, etc) and create a text field or something similar.

I’m still getting familiar with the lib, but it sounds like a reasonable operation.

What if comment these lines out:

Blockquote
lv_coord_t grid_w1 = lv_page_get_width_grid(rCont, 2, 1);

lv_obj_set_width(rCont, grid_w1);

That is exactly what seems to be the problem. I just reduced the code to basically that single line.

Is that something that I am not supposed to do?

Oh, you would like to check width of that cont you created.
Logically, the width of cont is not defined before set_width, what do you think?

So, I checked with him! In fact, we spend the whole afternoon talking about it :rofl:

I’m okay with get_width returning 0 if that was the case. But like I mentioned, this is a strip-down version of the code (the original one does set width).

The problem is when lv_page_get_width_grid gets called, it starts looking for properties and other friends of rCont. More specific, ext_attr. However for some reason ext_attr, tha is a pointer points to a random memory address!

Alright… I got it… I should be using lv_obj_get_width_grid :man_facepalming: :man_facepalming: :man_facepalming:

That’s what you get when using copy and paste! :sweat_smile: