How-to use Spinbox on tabview with a theme


When I use a theme, the Spinbox on tabview gives nullpointer on font.
When I remove the theem all is ok. Do I need to add a setting to the Spinbox to make this work?

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

emulator on windows

What do you experience?

When I add a theme to the app I get a chrash with null pointer on my Spinbox. When I remove the theme all is ok.

Exception thrown: read access violation.
font_p was nullptr.

on this code from lv_font.h

static inline uint8_t lv_font_get_line_height(const lv_font_t * font_p)
    return font_p->line_height;

What do you expect?

Spinbox on tabview

Code to reproduce

when I use the theme from the following code and then run the test_gui I get the crash:
When I do nut use the theme the app runs fine.

	lv_theme_t* th = lv_theme_night_init(210, &lv_font_roboto_16);     //Set a HUE value and a Font for the Night Theme
	lv_theme_set_current(th); //when removed Spinbox works fine
void test_gui() {
	lv_coord_t hres = lv_disp_get_hor_res(NULL);
	lv_coord_t vres = lv_disp_get_ver_res(NULL);

	lv_obj_t* tv = lv_tabview_create(lv_disp_get_scr_act(NULL), NULL);
	lv_obj_set_size(tv, hres, vres);
	lv_obj_t* tab1 = lv_tabview_add_tab(tv, "Write");
	lv_obj_t* tab2 = lv_tabview_add_tab(tv, "List");
	lv_obj_t* tab3 = lv_tabview_add_tab(tv, "Terminal");
	lv_page_set_sb_mode(tab3, LV_SB_MODE_OFF);

	lv_spinbox_create(tab1, NULL);

Without theme:

with theme:

I’ve just fixed it in the master branch.

Yes tested this and now it works.

1 Like

Can you tell me what release should this fix be in?
I am experiencing the exact same problem and I am using version 6.1.2.

The last v6 version is available here:

The fix should be there.

Thankyou for that, i have downloaded it and confirmed that the problem is still there. So i did some investigation and found that the copy i had, had been modified locally…and these mods caused the problem :frowning:
So, everything is now working fine with the latest unmodified code :slight_smile:
One question about the latest version 6 code.
If I find a problem with it, are you still accepting pull requests for it or do you consider the version 6 tree closed?

We’ll take most bugfixes provided that they’re unlikely to break existing code.

Hello kisvegabor,
Sorry to bother you with this but, last time i asked about this, I had confirmed it was working. BUT, what i didn’t realise was it works on an embedded platform (by accident) but fails in the simulator. I have traced it down to the style for the cursor (for the spinbox) being set to null and hence so is the font. On my embedded platform (stm32) it actually de-references the null pointer (for the font) to a usable value and managed to carry on. In the simulator, it fails straight away.
I have checked out the latest code as pointed to by the link you provided and have used the code that was provided at the top of the page and can confirm it still fails in the simulator.
Could this change have been checked into git and then lost through a merge or some other operation later on?
Can you tell me what changes you made to fix this?


So is it fail with a simple lv_spinbox_create(lv_scr_act(), NULL); too?

Can you tell in which function does it fail?

Sorry, only just realized you responded a week ago.
It fails in lv_font_get_line_height(const lv_font_t* font_p) because font_p is NULL

The spinbox is a child of a tile_object for a tile view

    lv_obj_t* tile_blank = lv_obj_create (parent_object, copy_ref_obj);
    lv_tileview_add_element(parent_object, tile_blank);
    lv_obj_t* sb=lv_spinbox_create(tile_blank, NULL);
    lv_group_add_obj(pbUserData->group, sb);

In spinbox_init() in the theme we are using, if i comment out the following line, it will work. =;

( is set to NULL in the theme)

I originally thought someone here had modified the theme incorrectly, but then having looked at the themes in the repo, they are all set the same.

Thanks for your help