determine required size of the th_styles array at compile time and remove runtime assertion
@@ -34,10 +34,8 @@ static lv_theme_t * current_theme;
* This way the theme styles will always point to the same memory address even after theme is change.
* (The pointers in the theme points to the styles declared by the theme itself) */
-/* Store the styles in this array.
- * Can't determine the size in compile time because sizeof is not evaluated (should be `sizeof(lv_theme_t) / sizeof(lv_style_t*)`).
- * Error will be generated in run time if too small.*/
-static lv_style_t th_styles[120];
+/* Store the styles in this array. */
+static lv_style_t th_styles[sizeof(((lv_theme_t *)0)->style) / sizeof(lv_style_t *)];
static bool inited = false;
static lv_theme_t current_theme;
#endif
@@ -63,12 +61,6 @@ void lv_theme_set_current(lv_theme_t * th)
uint32_t style_num = sizeof(th->style) / sizeof(lv_style_t *); /*Number of styles in a theme*/
if(!inited) {
- /*It's not sure `th_styles` is big enough. Check it now!*/
- if(style_num > sizeof(th_styles) / sizeof(lv_style_t)) {
- LV_LOG_ERROR("Themes: th_styles array is too small. Increase it's size!");
- while(1);
- }
-
/*Initialize the style pointers `current_theme` to point to the `th_styles` style array */
uint16_t i;
lv_style_t ** cur_th_style_p = (lv_style_t **) &current_theme.style;
