Description
When using lv_obj_set_style_base_dir(parent, LV_BASE_DIR_RTL, 0); and creating a roller, my program crashes.
What MCU/Processor/Board and compiler are you using?
Visual studio 2019 simulator
What LVGL version are you using?
8.3
What do you want to achieve?
Set an object from right to left and create a roller inside it
What have you tried so far?
In demo widget (profile_create) I tried to write this code:
lv_obj_set_style_base_dir(parent, LV_BASE_DIR_RTL, 0);
lv_obj_t* roller = lv_roller_create(parent);
but I get the same error message
bader
September 24, 2023, 10:08pm
2
Hi,
I think the problem is in the function get_selected_label_width()
get_selected_label_width()
was called indirectly by lv_obj_get_self_width(obj)
inside lv_obj_get_scroll_left()
The get_selected_label_width()
function supposedly takes an obj with lv_label_class, but in this case, the function was passed to it an object with lv_obj_class.
So, I think it should return 0 if the object passed to it is NULL or it has other than lv_lable class. (I don’t know if that is correct for all scenarios).
.
Logical but not verified workaround :
static lv_coord_t get_selected_label_width(const lv_obj_t * obj)
{
lv_obj_t * label = get_label(obj);
if(label == NULL || label->class_p != &lv_label_class) return 0;
const lv_font_t * font = lv_obj_get_style_text_font(obj, LV_PART_SELECTED);
lv_coord_t letter_space = lv_obj_get_style_text_letter_space(obj, LV_PART_SELECTED);
const char * txt = lv_label_get_text(label);
lv_point_t size;
lv_txt_get_size(&size, txt, font, letter_space, 0, LV_COORD_MAX, LV_TEXT_FLAG_NONE);
return size.x;
}
.
Best Regards,
Bader