I’m developing a Software on Linux and using LVGL with SDL2 backend.
I’m still testing if everything works as it should and now I have a problem with label (might be that it happens with other widgets, haven’t tested).
I initialize the style (which is static - or in this case c++ member variable:
lv_style_init(&header_text_style_);
lv_style_set_text_color(&header_text_style_, lv_color_white());
lv_style_set_text_align(&header_text_style_, LV_TEXT_ALIGN_RIGHT);
Actually it doesn’t matter what the second style is.
Then I create one label:
lv_obj_t *header = lv_label_create(lv_scr_act());
lv_obj_set_pos(header, static_cast<lv_coord_t>(20), static_cast<lv_coord_t>(9));
lv_obj_set_size(header, static_cast<lv_coord_t>(300), static_cast<lv_coord_t>(31));
lv_obj_set_style_text_align(header, LV_TEXT_ALIGN_LEFT, 0);
lv_obj_add_style(header, &header_text_style_, 0);
lv_label_set_text_static(header, "HELLO");
And the segmentaion fault comes in lv_style.h →
static inline lv_res_t lv_style_get_prop_inlined(const lv_style_t * style, lv_style_prop_t prop, lv_style_value_t * value)
...
for(i = 0; i < style->prop_cnt; i++) {
if(props[i] == prop) {
because style->v_p.values_and_props points to memory which is not accessible.
I have tried this with master branch and whit 8.2 and 8.3 and I get always the problem. Also if I use only only one style (text color), it doesn’t crash, but the text doesn’t take the wanted color.
I have been successfully using LVGL with c++ on different ARM controllers, but now with Linux the simplest thing doesn’t work
Any suggestions what it could be? I have enabled all the asserts and the log from lv_conf.h, but it doesn’t say anything which could help on this. I have tried this with different memory allocators, but the result is always the same.
EDIT: I forgot to tell, that the demo (lv_demo_widgets) works without problems.
[Info] (0.000, +0) lv_label_create: begin (in lv_label.c line #75)
[Trace] (0.000, +0) lv_obj_class_create_obj: Creating object with 0x555555619520 class on 0x555555a05648 parent (in lv_obj_class.c line #45)
[Trace] (0.000, +0) lv_mem_alloc: allocating 104 bytes (in lv_mem.c line #125)
[Trace] (0.000, +0) lv_mem_alloc: allocated at 0x555555a05ce0 (in lv_mem.c line #151)
[Trace] (0.000, +0) lv_obj_class_create_obj: creating normal object (in lv_obj_class.c line #81)
[Trace] (0.000, +0) lv_mem_alloc: allocating 48 bytes (in lv_mem.c line #125)
[Trace] (0.000, +0) lv_mem_alloc: allocated at 0x555555a05d50 (in lv_mem.c line #151)
[Trace] (0.000, +0) lv_mem_alloc: allocating 8 bytes (in lv_mem.c line #125)
[Trace] (0.000, +0) lv_mem_alloc: allocated at 0x555555a05d88 (in lv_mem.c line #151)
[Trace] (0.000, +0) lv_obj_constructor: begin (in lv_obj.c line #398)
[Trace] (0.000, +0) lv_obj_constructor: finished (in lv_obj.c line #423)
[Trace] (0.000, +0) lv_label_constructor: begin (in lv_label.c line #691)
[Trace] (0.000, +0) lv_mem_alloc: allocating 5 bytes (in lv_mem.c line #125)
[Trace] (0.000, +0) lv_mem_alloc: allocated at 0x555555a05da8 (in lv_mem.c line #151)
[Trace] (0.000, +0) lv_label_constructor: finished (in lv_label.c line #721)
[Trace] (0.000, +0) event_send_core: Sending event 42 to 0x555555a05ce0 with (nil) param (in lv_event.c line #428)
[Trace] (0.000, +0) event_send_core: Sending event 19 to 0x555555a05ce0 with 0x7fffffffe344 param (in lv_event.c line #428)
[Trace] (0.000, +0) lv_mem_alloc: allocating 48 bytes (in lv_mem.c line #125)
[Trace] (0.000, +0) lv_mem_alloc: allocated at 0x555555a05dc8 (in lv_mem.c line #151)
[Trace] (0.000, +0) event_send_core: Sending event 34 to 0x555555a05648 with 0x555555a05ce0 param (in lv_event.c line #428)
[Trace] (0.000, +0) event_send_core: Sending event 35 to 0x555555a05648 with 0x555555a05ce0 param (in lv_event.c line #428)
[Trace] (0.000, +0) lv_mem_realloc: reallocating (nil) with 16 size (in lv_mem.c line #184)
[Trace] (0.000, +0) lv_mem_realloc: allocated at 0x555555a05e00 (in lv_mem.c line #203)
[Trace] (0.000, +0) lv_mem_alloc: allocating 24 bytes (in lv_mem.c line #125)
[Trace] (0.000, +0) lv_mem_alloc: allocated at 0x555555a05e20 (in lv_mem.c line #151)
[Trace] (0.000, +0) event_send_core: Sending event 42 to 0x555555a05ce0 with (nil) param (in lv_event.c line #428)
[Trace] (0.000, +0) lv_mem_alloc: allocating 20 bytes (in lv_mem.c line #125)
[Trace] (0.000, +0) lv_mem_alloc: allocated at 0x555555a05e40 (in lv_mem.c line #151)
[Trace] (0.000, +0) event_send_core: Sending event 42 to 0x555555a05ce0 with (nil) param (in lv_event.c line #428)
[Trace] (0.000, +0) lv_mem_realloc: reallocating 0x555555a05e40 with 30 size (in lv_mem.c line #184)
[Trace] (0.000, +0) lv_mem_realloc: allocated at 0x555555a05e40 (in lv_mem.c line #203)
[Trace] (0.000, +0) event_send_core: Sending event 42 to 0x555555a05ce0 with (nil) param (in lv_event.c line #428)
[Trace] (0.000, +0) lv_mem_realloc: reallocating 0x555555a05e40 with 40 size (in lv_mem.c line #184)
[Trace] (0.000, +0) lv_mem_realloc: allocated at 0x555555a05e40 (in lv_mem.c line #203)
[Trace] (0.000, +0) event_send_core: Sending event 42 to 0x555555a05ce0 with (nil) param (in lv_event.c line #428)
[Trace] (0.000, +0) lv_mem_realloc: reallocating 0x555555a05e40 with 50 size (in lv_mem.c line #184)
[Trace] (0.000, +0) lv_mem_realloc: allocated at 0x555555a05e40 (in lv_mem.c line #203)
[Trace] (0.000, +0) event_send_core: Sending event 42 to 0x555555a05ce0 with (nil) param (in lv_event.c line #428)
[Trace] (0.000, +0) lv_mem_realloc: reallocating 0x555555a05e00 with 32 size (in lv_mem.c line #184)
[Trace] (0.000, +0) lv_mem_realloc: allocated at 0x555555a05e80 (in lv_mem.c line #203)
[Trace] (0.000, +0) event_send_core: Sending event 42 to 0x555555a05ce0 with (nil) param (in lv_event.c line #428)
[Trace] (0.000, +0) event_send_core: Sending event 19 to 0x555555a05ce0 with 0x7fffffffe364 param (in lv_event.c line #428)
[Trace] (0.000, +0) lv_mem_free: freeing 0x555555a05da8 (in lv_mem.c line #161)
[Trace] (0.005, +5) lv_timer_handler: begin (in lv_timer.c line #69)
[Trace] (0.005, +0) lv_timer_exec: calling timer callback: 0x55555557943e (in lv_timer.c line #312)
[Trace] (0.005, +0) _lv_disp_refr_timer: begin (in lv_refr.c line #277)
[Info] (0.005, +0) lv_obj_update_layout: Layout update begin (in lv_obj_pos.c line #311)
[Trace] (0.005, +0) event_send_core: Sending event 41 to 0x555555a05ce0 with 0x7fffffffdf00 param (in lv_event.c line #428)