mirror of
https://github.com/lvgl/lvgl.git
synced 2026-08-17 01:31:53 +08:00
feat(core): add lv_check_arg to public functions in lv_obj (#10196)
Arduino Lint / lint (push) Has been cancelled
Build Examples with C++ Compiler / build-examples (push) Has been cancelled
MicroPython CI / Build esp32 port (push) Has been cancelled
MicroPython CI / Build rp2 port (push) Has been cancelled
MicroPython CI / Build stm32 port (push) Has been cancelled
MicroPython CI / Build unix port (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_NORMAL_8BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_SDL - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build ESP IDF ESP32S3 (push) Has been cancelled
C/C++ CI / Run tests with 32bit build (push) Has been cancelled
C/C++ CI / Run tests with 64bit build (push) Has been cancelled
BOM Check / bom-check (push) Has been cancelled
Verify that lv_conf_internal.h matches repository state / verify-conf-internal (push) Has been cancelled
Verify GDB constants are up-to-date / verify-gdb-consts (push) Has been cancelled
Verify the widget property name / verify-property-name (push) Has been cancelled
Verify code formatting / verify-formatting (push) Has been cancelled
Compare file templates with file names / template-check (push) Has been cancelled
Build Docs / build-and-deploy (push) Has been cancelled
Build .deb packages / build (push) Has been cancelled
Test API JSON generator / Test API JSON (push) Has been cancelled
Install LVGL using CMake / build-examples (private) (push) Has been cancelled
Install LVGL using CMake / build-examples (public) (push) Has been cancelled
Check Makefile / Build using Makefile (push) Has been cancelled
Check Makefile for UEFI / Build using Makefile for UEFI (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/benchmark_results_comment/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/filter_docker_logs/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/serialize_results/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 32b - lv_conf_perf32b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 64b - lv_conf_perf64b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Save PR Number (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_32B - Ubuntu (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_64B - Ubuntu (push) Has been cancelled
Port repo release update / run-release-branch-updater (push) Has been cancelled
Static Checks / Static Checks (push) Has been cancelled
Verify Font License / verify-font-license (push) Has been cancelled
Verify Kconfig / verify-kconfig (push) Has been cancelled
Hardware Performance Test / Hardware Performance Benchmark (push) Has been cancelled
Hardware Performance Test / HW Benchmark - Save PR Number (push) Has been cancelled
Arduino Lint / lint (push) Has been cancelled
Build Examples with C++ Compiler / build-examples (push) Has been cancelled
MicroPython CI / Build esp32 port (push) Has been cancelled
MicroPython CI / Build rp2 port (push) Has been cancelled
MicroPython CI / Build stm32 port (push) Has been cancelled
MicroPython CI / Build unix port (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_NORMAL_8BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_SDL - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build ESP IDF ESP32S3 (push) Has been cancelled
C/C++ CI / Run tests with 32bit build (push) Has been cancelled
C/C++ CI / Run tests with 64bit build (push) Has been cancelled
BOM Check / bom-check (push) Has been cancelled
Verify that lv_conf_internal.h matches repository state / verify-conf-internal (push) Has been cancelled
Verify GDB constants are up-to-date / verify-gdb-consts (push) Has been cancelled
Verify the widget property name / verify-property-name (push) Has been cancelled
Verify code formatting / verify-formatting (push) Has been cancelled
Compare file templates with file names / template-check (push) Has been cancelled
Build Docs / build-and-deploy (push) Has been cancelled
Build .deb packages / build (push) Has been cancelled
Test API JSON generator / Test API JSON (push) Has been cancelled
Install LVGL using CMake / build-examples (private) (push) Has been cancelled
Install LVGL using CMake / build-examples (public) (push) Has been cancelled
Check Makefile / Build using Makefile (push) Has been cancelled
Check Makefile for UEFI / Build using Makefile for UEFI (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/benchmark_results_comment/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/filter_docker_logs/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/serialize_results/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 32b - lv_conf_perf32b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 64b - lv_conf_perf64b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Save PR Number (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_32B - Ubuntu (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_64B - Ubuntu (push) Has been cancelled
Port repo release update / run-release-branch-updater (push) Has been cancelled
Static Checks / Static Checks (push) Has been cancelled
Verify Font License / verify-font-license (push) Has been cancelled
Verify Kconfig / verify-kconfig (push) Has been cancelled
Hardware Performance Test / Hardware Performance Benchmark (push) Has been cancelled
Hardware Performance Test / HW Benchmark - Save PR Number (push) Has been cancelled
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
6fa9acedef
commit
bbedf26560
+1
-1
@@ -172,7 +172,7 @@ void lv_group_swap_obj(lv_obj_t * obj1, lv_obj_t * obj2)
|
||||
else if((*obj_i) == obj2)(*obj_i) = obj1;
|
||||
}
|
||||
|
||||
// Swap the focus as well.
|
||||
/* Swap the focus as well. */
|
||||
lv_obj_t * focused = lv_group_get_focused(g1);
|
||||
if(focused == obj1) lv_group_focus_obj(obj2);
|
||||
else if(focused == obj2) lv_group_focus_obj(obj1);
|
||||
|
||||
+19
-11
@@ -327,6 +327,7 @@ void lv_obj_remove_flag(lv_obj_t * obj, lv_obj_flag_t f)
|
||||
|
||||
void lv_obj_set_flag(lv_obj_t * obj, lv_obj_flag_t f, bool v)
|
||||
{
|
||||
LV_CHECK_OBJ(obj, MY_CLASS, return);
|
||||
if(v) lv_obj_add_flag(obj, f);
|
||||
else lv_obj_remove_flag(obj, f);
|
||||
}
|
||||
@@ -359,6 +360,7 @@ void lv_obj_remove_state(lv_obj_t * obj, lv_state_t state)
|
||||
|
||||
void lv_obj_set_state(lv_obj_t * obj, lv_state_t state, bool v)
|
||||
{
|
||||
LV_CHECK_OBJ(obj, MY_CLASS, return);
|
||||
if(v) lv_obj_add_state(obj, state);
|
||||
else lv_obj_remove_state(obj, state);
|
||||
}
|
||||
@@ -486,12 +488,14 @@ lv_obj_spec_attr_t * lv_obj_allocate_spec_attr(lv_obj_t * obj)
|
||||
bool lv_obj_check_type(const lv_obj_t * obj, const lv_obj_class_t * class_p)
|
||||
{
|
||||
LV_CHECK_ARG(obj != NULL, return false);
|
||||
LV_CHECK_ARG(class_p != NULL, return false);
|
||||
return obj->class_p == class_p;
|
||||
}
|
||||
|
||||
bool lv_obj_has_class(const lv_obj_t * obj, const lv_obj_class_t * class_p)
|
||||
{
|
||||
LV_CHECK_ARG(obj != NULL, return false);
|
||||
LV_CHECK_ARG(class_p != NULL, return false);
|
||||
|
||||
const lv_obj_class_t * obj_class = obj->class_p;
|
||||
while(obj_class) {
|
||||
@@ -504,13 +508,13 @@ bool lv_obj_has_class(const lv_obj_t * obj, const lv_obj_class_t * class_p)
|
||||
|
||||
const lv_obj_class_t * lv_obj_get_class(const lv_obj_t * obj)
|
||||
{
|
||||
LV_CHECK_ARG(obj != NULL, return NULL);
|
||||
LV_CHECK_ARG(obj != NULL, return NULL); /* Can't use LV_CHECK_OBJ here, it could cause an infinite recursion loop. */
|
||||
return obj->class_p;
|
||||
}
|
||||
|
||||
bool lv_obj_is_valid(const lv_obj_t * obj)
|
||||
{
|
||||
LV_CHECK_ARG(obj != NULL, return false);
|
||||
LV_CHECK_ARG(obj != NULL, return false); /* Can't use LV_CHECK_OBJ here, it could cause an infinite recursion loop. */
|
||||
|
||||
lv_display_t * disp = lv_display_get_next(NULL);
|
||||
while(disp) {
|
||||
@@ -570,6 +574,7 @@ lv_obj_t * lv_obj_find_by_id(const lv_obj_t * obj, const void * id)
|
||||
void lv_obj_add_screen_load_event(lv_obj_t * obj, lv_event_code_t trigger, lv_obj_t * screen,
|
||||
lv_screen_load_anim_t anim_type, uint32_t duration, uint32_t delay)
|
||||
{
|
||||
LV_CHECK_OBJ(obj, MY_CLASS, return);
|
||||
LV_CHECK_ARG(screen != NULL, return, "can't load a non-existing screen");
|
||||
LV_CHECK_ARG(duration > 0 || anim_type == LV_SCREEN_LOAD_ANIM_NONE, return);
|
||||
|
||||
@@ -588,6 +593,8 @@ void lv_obj_add_screen_load_event(lv_obj_t * obj, lv_event_code_t trigger, lv_ob
|
||||
void lv_obj_add_screen_create_event(lv_obj_t * obj, lv_event_code_t trigger, lv_screen_create_cb_t screen_create_cb,
|
||||
lv_screen_load_anim_t anim_type, uint32_t duration, uint32_t delay)
|
||||
{
|
||||
LV_CHECK_OBJ(obj, MY_CLASS, return);
|
||||
LV_CHECK_ARG(screen_create_cb != NULL, return);
|
||||
LV_CHECK_ARG(duration > 0 || anim_type == LV_SCREEN_LOAD_ANIM_NONE, return);
|
||||
|
||||
screen_load_anim_dsc_t * dsc = lv_malloc(sizeof(screen_load_anim_dsc_t));
|
||||
@@ -605,7 +612,7 @@ void lv_obj_add_screen_create_event(lv_obj_t * obj, lv_event_code_t trigger, lv_
|
||||
void lv_obj_add_play_timeline_event(lv_obj_t * obj, lv_event_code_t trigger, lv_anim_timeline_t * at, uint32_t delay,
|
||||
bool reverse)
|
||||
{
|
||||
LV_CHECK_ARG(obj != NULL, return);
|
||||
LV_CHECK_OBJ(obj, MY_CLASS, return);
|
||||
LV_CHECK_ARG(at != NULL, return);
|
||||
|
||||
timeline_play_dsc_t * dsc = lv_malloc(sizeof(timeline_play_dsc_t));
|
||||
@@ -621,20 +628,20 @@ void lv_obj_add_play_timeline_event(lv_obj_t * obj, lv_event_code_t trigger, lv_
|
||||
|
||||
void lv_obj_set_user_data(lv_obj_t * obj, void * user_data)
|
||||
{
|
||||
LV_CHECK_ARG(obj != NULL, return);
|
||||
LV_CHECK_OBJ(obj, MY_CLASS, return);
|
||||
obj->user_data = user_data;
|
||||
}
|
||||
|
||||
void * lv_obj_get_user_data(lv_obj_t * obj)
|
||||
{
|
||||
LV_CHECK_ARG(obj != NULL, return NULL);
|
||||
LV_CHECK_OBJ(obj, MY_CLASS, return NULL);
|
||||
|
||||
return obj->user_data;
|
||||
}
|
||||
|
||||
lv_delete_dsc_t * lv_obj_add_delete_cb(lv_obj_t * obj, lv_delete_cb_t cb, void * user_data)
|
||||
{
|
||||
LV_CHECK_ARG(obj != NULL, return NULL);
|
||||
LV_CHECK_OBJ(obj, MY_CLASS, return NULL);
|
||||
LV_CHECK_ARG(cb != NULL, return NULL);
|
||||
|
||||
lv_delete_dsc_t * dsc = lv_malloc(sizeof(*dsc));
|
||||
@@ -673,7 +680,7 @@ void lv_obj_remove_delete_cb(lv_delete_dsc_t * dsc)
|
||||
|
||||
static void lv_obj_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
||||
{
|
||||
LV_CHECK_ARG(obj != NULL, return);
|
||||
LV_ASSERT(obj != NULL);
|
||||
|
||||
LV_UNUSED(class_p);
|
||||
LV_TRACE_OBJ_CREATE("begin");
|
||||
@@ -710,7 +717,7 @@ static void lv_obj_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
||||
|
||||
static void lv_obj_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
||||
{
|
||||
LV_CHECK_ARG(obj != NULL, return);
|
||||
LV_ASSERT(obj != NULL);
|
||||
|
||||
LV_UNUSED(class_p);
|
||||
|
||||
@@ -1184,9 +1191,10 @@ static void lv_obj_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
||||
*/
|
||||
static void update_obj_state(lv_obj_t * obj, lv_state_t new_state)
|
||||
{
|
||||
LV_ASSERT(obj != NULL);
|
||||
|
||||
if(obj->state == new_state) return;
|
||||
|
||||
LV_CHECK_OBJ(obj, MY_CLASS, return);
|
||||
|
||||
lv_state_t prev_state = obj->state;
|
||||
|
||||
@@ -1414,7 +1422,7 @@ static lv_point_t lv_obj_get_scroll_end_helper(lv_obj_t * obj)
|
||||
|
||||
static lv_result_t lv_obj_set_any(lv_obj_t * obj, lv_prop_id_t id, const lv_property_t * prop)
|
||||
{
|
||||
LV_CHECK_OBJ(obj, MY_CLASS, return LV_RESULT_INVALID);
|
||||
LV_ASSERT(obj != NULL);
|
||||
|
||||
if(id >= LV_PROPERTY_OBJ_FLAG_START && id <= LV_PROPERTY_OBJ_FLAG_END) {
|
||||
lv_obj_flag_t flag = 1L << (id - LV_PROPERTY_OBJ_FLAG_START);
|
||||
@@ -1439,7 +1447,7 @@ static lv_result_t lv_obj_set_any(lv_obj_t * obj, lv_prop_id_t id, const lv_prop
|
||||
|
||||
static lv_result_t lv_obj_get_any(const lv_obj_t * obj, lv_prop_id_t id, lv_property_t * prop)
|
||||
{
|
||||
LV_CHECK_OBJ(obj, MY_CLASS, return LV_RESULT_INVALID);
|
||||
LV_ASSERT(obj != NULL);
|
||||
if(id >= LV_PROPERTY_OBJ_FLAG_START && id <= LV_PROPERTY_OBJ_FLAG_END) {
|
||||
lv_obj_flag_t flag = 1L << (id - LV_PROPERTY_OBJ_FLAG_START);
|
||||
prop->id = id;
|
||||
|
||||
@@ -97,6 +97,7 @@ const char * lv_obj_stringify_id(lv_obj_t * obj, char * buf, uint32_t len)
|
||||
LV_CHECK_ARG(obj != NULL, return NULL);
|
||||
LV_CHECK_ARG(obj->class_p != NULL, return NULL);
|
||||
LV_CHECK_ARG(buf != NULL, return NULL);
|
||||
LV_CHECK_ARG(len > 0, return NULL);
|
||||
|
||||
const char * name = obj->class_p->name;
|
||||
if(name == NULL) name = "nameless";
|
||||
|
||||
Reference in New Issue
Block a user