fix(example_grad): return value from lv_style_get_prop not checked (#7793)

This commit is contained in:
Paul Vogel
2025-02-18 20:36:37 -06:00
committed by GitHub
parent d22bf032b1
commit 77f8f62d18
+10 -2
View File
@@ -21,7 +21,10 @@ static void frac_1_event_cb(lv_event_t * e)
{ {
lv_style_t * style = lv_event_get_user_data(e); lv_style_t * style = lv_event_get_user_data(e);
lv_style_value_t v; lv_style_value_t v;
lv_style_get_prop(style, LV_STYLE_BG_GRAD, &v); if(lv_style_get_prop(style, LV_STYLE_BG_GRAD, &v) != LV_STYLE_RES_FOUND) {
LV_LOG_WARN("style prop not found");
}
else {
lv_grad_dsc_t * dsc = (lv_grad_dsc_t *)v.ptr; lv_grad_dsc_t * dsc = (lv_grad_dsc_t *)v.ptr;
lv_point_t p; lv_point_t p;
@@ -33,12 +36,16 @@ static void frac_1_event_cb(lv_event_t * e)
lv_obj_invalidate(parent); lv_obj_invalidate(parent);
} }
}
static void frac_2_event_cb(lv_event_t * e) static void frac_2_event_cb(lv_event_t * e)
{ {
lv_style_t * style = lv_event_get_user_data(e); lv_style_t * style = lv_event_get_user_data(e);
lv_style_value_t v; lv_style_value_t v;
lv_style_get_prop(style, LV_STYLE_BG_GRAD, &v); if(lv_style_get_prop(style, LV_STYLE_BG_GRAD, &v) != LV_STYLE_RES_FOUND) {
LV_LOG_WARN("style prop not found");
}
else {
lv_grad_dsc_t * dsc = (lv_grad_dsc_t *)v.ptr; lv_grad_dsc_t * dsc = (lv_grad_dsc_t *)v.ptr;
lv_point_t p; lv_point_t p;
@@ -50,6 +57,7 @@ static void frac_2_event_cb(lv_event_t * e)
dsc->stops[1].frac = LV_CLAMP(0, p.x * 255 / lv_obj_get_width(parent), 255); dsc->stops[1].frac = LV_CLAMP(0, p.x * 255 / lv_obj_get_width(parent), 255);
lv_obj_invalidate(parent); lv_obj_invalidate(parent);
} }
}
/** /**
* Play with a simple horizontal gradient. * Play with a simple horizontal gradient.