From 366f958e1a57a9f86ee81402c4a015537e111f1a Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 24 Sep 2019 16:30:38 +0200 Subject: [PATCH] debug: add the basics of LV_DEBUG --- lvgl.h | 1 + src/lv_core/lv_debug.c | 143 ++++++++++++++++++++++++++++++++++ src/lv_core/lv_debug.h | 85 ++++++++++++++++++++ src/lv_core/lv_group.c | 7 +- src/lv_core/lv_obj.c | 5 +- src/lv_core/lv_style.c | 3 +- src/lv_draw/lv_draw.c | 5 +- src/lv_draw/lv_img_cache.c | 3 +- src/lv_draw/lv_img_decoder.c | 13 ++-- src/lv_font/lv_font_fmt_txt.c | 3 +- src/lv_hal/lv_hal_disp.c | 5 +- src/lv_hal/lv_hal_indev.c | 3 +- src/lv_misc/lv_anim.c | 3 +- src/lv_misc/lv_fs.c | 7 +- src/lv_misc/lv_mem.h | 21 ----- src/lv_misc/lv_task.c | 9 ++- src/lv_objx/lv_arc.c | 5 +- src/lv_objx/lv_bar.c | 5 +- src/lv_objx/lv_btn.c | 5 +- src/lv_objx/lv_btnm.c | 9 ++- src/lv_objx/lv_calendar.c | 5 +- src/lv_objx/lv_canvas.c | 5 +- src/lv_objx/lv_cb.c | 5 +- src/lv_objx/lv_chart.c | 13 ++-- src/lv_objx/lv_cont.c | 5 +- src/lv_objx/lv_ddlist.c | 5 +- src/lv_objx/lv_gauge.c | 7 +- src/lv_objx/lv_img.c | 7 +- src/lv_objx/lv_imgbtn.c | 7 +- src/lv_objx/lv_kb.c | 7 +- src/lv_objx/lv_label.c | 23 ++++-- src/lv_objx/lv_led.c | 5 +- src/lv_objx/lv_line.c | 5 +- src/lv_objx/lv_list.c | 5 +- src/lv_objx/lv_lmeter.c | 5 +- src/lv_objx/lv_mbox.c | 5 +- src/lv_objx/lv_objx_templ.c | 1 + src/lv_objx/lv_page.c | 5 +- src/lv_objx/lv_preload.c | 5 +- src/lv_objx/lv_roller.c | 9 ++- src/lv_objx/lv_slider.c | 5 +- src/lv_objx/lv_spinbox.c | 5 +- src/lv_objx/lv_sw.c | 5 +- src/lv_objx/lv_ta.c | 17 ++-- src/lv_objx/lv_table.c | 5 +- src/lv_objx/lv_tabview.c | 13 ++-- src/lv_objx/lv_tileview.c | 5 +- src/lv_objx/lv_win.c | 5 +- 48 files changed, 397 insertions(+), 137 deletions(-) create mode 100644 src/lv_core/lv_debug.c create mode 100644 src/lv_core/lv_debug.h diff --git a/lvgl.h b/lvgl.h index b6e29b61b..5fe452834 100644 --- a/lvgl.h +++ b/lvgl.h @@ -28,6 +28,7 @@ extern "C" { #include "src/lv_core/lv_refr.h" #include "src/lv_core/lv_disp.h" +#include "src/lv_core/lv_debug.h" #include "src/lv_themes/lv_theme.h" diff --git a/src/lv_core/lv_debug.c b/src/lv_core/lv_debug.c new file mode 100644 index 000000000..b1792075a --- /dev/null +++ b/src/lv_core/lv_debug.c @@ -0,0 +1,143 @@ +/** + * @file lv_debug.c + * + */ + +/********************* + * INCLUDES + *********************/ +#include "lv_obj.h" + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * STATIC PROTOTYPES + **********************/ +static bool obj_valid_child(lv_obj_t * parent, lv_obj_t * obj_to_find); + +/********************** + * STATIC VARIABLES + **********************/ + +/********************** + * MACROS + **********************/ + +/********************** + * GLOBAL FUNCTIONS + **********************/ + +bool lv_debug_check_null(const void * p) +{ + if(p) return true; + + return false; +} + +bool lv_debug_check_obj_type(lv_obj_t * obj, const char * obj_type) +{ + lv_obj_type_t types; + lv_obj_get_type(obj, &types); + + uint8_t i; + for(i = 0; i < LV_MAX_ANCESTOR_NUM; i++) { + if(strcmp(types.type[i], obj_type) == 0) return true; + } + + return false; +} + +bool lv_debug_check_obj_valid(lv_obj_t * obj) +{ + lv_disp_t * disp = lv_disp_get_next(NULL); + while(disp) { + lv_obj_t * scr; + LV_LL_READ(disp->scr_ll, scr) { + + if(scr == obj) return true; + bool found = obj_valid_child(scr, obj); + if(found) return true; + } + + disp = lv_disp_get_next(disp); + } + + return false; +} + +bool lv_debug_check_malloc(void * p) +{ + if(p) return true; + + return false; +} + +void lv_debug_log_error(const char * msg, unsigned long int value) +{ + static const char hex[] = "0123456789ABCDEF"; + + uint32_t msg_len = strlen(msg); + uint32_t value_len = sizeof(unsigned long int); + + if(msg_len < 230) { + char buf[255]; + char * bufp = buf; + + /*Add the function name*/ + memcpy(bufp, msg, msg_len); + bufp += msg_len; + + /*Add value in hey*/ + *bufp = ' '; + bufp ++; + *bufp = '('; + bufp ++; + *bufp = '0'; + bufp ++; + *bufp = 'x'; + bufp ++; + + int8_t i; + for(i = value_len * 2 - 1; i >= 0; i--) { + uint8_t x = (unsigned long int)((unsigned long int)value >> (i * 4)) & 0xF; + + *bufp = hex[x]; + bufp++; + } + + *bufp = ')'; + bufp ++; + + *bufp = '\0'; + LV_LOG_ERROR(buf); + } else { + LV_LOG_ERROR(msg); + } +} + +/********************** + * STATIC FUNCTIONS + **********************/ + +static bool obj_valid_child(lv_obj_t * parent, lv_obj_t * obj_to_find) +{ + /*Check all children of `parent`*/ + lv_obj_t * child = lv_obj_get_child(parent, NULL); + while(child) { + if(child == obj_to_find) return true; + + /*Check the children*/ + bool found = obj_valid_child(child, obj_to_find); + if(found) return true; + + child = lv_obj_get_child(parent, child); + } + + return false; +} diff --git a/src/lv_core/lv_debug.h b/src/lv_core/lv_debug.h new file mode 100644 index 000000000..5d0c2236c --- /dev/null +++ b/src/lv_core/lv_debug.h @@ -0,0 +1,85 @@ +/** + * @file lv_debug.h + * + */ + +#ifndef LV_DEBUG_H +#define LV_DEBUG_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ +#include "lv_obj.h" + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * GLOBAL PROTOTYPES + **********************/ +bool lv_debug_check_null(const void * p); + +bool lv_debug_check_obj_type(lv_obj_t * obj, const char * obj_type); + +bool lv_debug_check_obj_valid(lv_obj_t * obj); + +bool lv_debug_check_malloc(void * p); + +void lv_debug_log_error(const char * msg, uint64_t value); + +/********************** + * MACROS + **********************/ + +#define LV_DEBUG_HALT(msg, value) \ + { \ + lv_debug_log_error(msg, value); \ + while(1); \ + } \ + +#ifndef LV_ASSERT_NULL +#define LV_ASSERT_NULL(p) \ + if(lv_debug_check_null(p) == false) { \ + LV_LOG_ERROR(__func__); \ + LV_DEBUG_HALT("NULL obj. found", (lv_uintptr_t)p); \ + } +#endif + +#ifndef LV_ASSERT_OBJ_NOT_EXISTS +#define LV_ASSERT_OBJ_NOT_EXISTS(obj) \ + if(lv_debug_check_obj_valid(obj) == false) { \ + LV_LOG_ERROR(__func__); \ + LV_DEBUG_HALT("Invalid obj, found", (lv_uintptr_t)obj); \ + } +#endif + +#ifndef LV_ASSERT_OBJ_TYPE_ERROR +#define LV_ASSERT_OBJ_TYPE_ERROR(obj, type) \ + if(lv_debug_check_obj_type(obj, __LV_OBJX_TYPE) == false) { \ + LV_LOG_ERROR(__func__); \ + LV_DEBUG_HALT("Obj. type mismatch", (lv_uintptr_t)obj); \ + } +#endif + +#ifndef LV_ASSERT_NO_MEM +#define LV_ASSERT_NO_MEM(p) \ + if(lv_debug_check_malloc(p) == false) { \ + LV_LOG_ERROR(__func__); \ + LV_DEBUG_HALT("Out of memory", (lv_uintptr_t)p); \ + } +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*LV_DEBUG_H*/ diff --git a/src/lv_core/lv_group.c b/src/lv_core/lv_group.c index d04de3eb3..4b3e3a203 100644 --- a/src/lv_core/lv_group.c +++ b/src/lv_core/lv_group.c @@ -8,8 +8,9 @@ *********************/ #include "lv_group.h" #if LV_USE_GROUP != 0 -#include "../lv_themes/lv_theme.h" #include +#include "../lv_core/lv_debug.h" +#include "../lv_themes/lv_theme.h" #include "../lv_misc/lv_gc.h" #if defined(LV_GC_INCLUDE) @@ -62,7 +63,7 @@ void lv_group_init(void) lv_group_t * lv_group_create(void) { lv_group_t * group = lv_ll_ins_head(&LV_GC_ROOT(_lv_group_ll)); - lv_mem_assert(group); + LV_ASSERT_NO_MEM(group); if(group == NULL) return NULL; lv_ll_init(&group->obj_ll, sizeof(lv_obj_t *)); @@ -138,7 +139,7 @@ void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj) obj->group_p = group; lv_obj_t ** next = lv_ll_ins_tail(&group->obj_ll); - lv_mem_assert(next); + LV_ASSERT_NO_MEM(next); if(next == NULL) return; *next = obj; diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index bb7b81299..d8965bbe5 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -11,6 +11,7 @@ #include "lv_refr.h" #include "lv_group.h" #include "lv_disp.h" +#include "../lv_core/lv_debug.h" #include "../lv_themes/lv_theme.h" #include "../lv_draw/lv_draw.h" #include "../lv_misc/lv_anim.h" @@ -142,7 +143,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy) } new_obj = lv_ll_ins_head(&disp->scr_ll); - lv_mem_assert(new_obj); + LV_ASSERT_NO_MEM(new_obj); if(new_obj == NULL) return NULL; new_obj->par = NULL; /*Screens has no a parent*/ @@ -215,7 +216,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy) LV_LOG_TRACE("Object create started"); new_obj = lv_ll_ins_head(&parent->child_ll); - lv_mem_assert(new_obj); + LV_ASSERT_NO_MEM(new_obj); if(new_obj == NULL) return NULL; new_obj->par = parent; /*Set the parent*/ diff --git a/src/lv_core/lv_style.c b/src/lv_core/lv_style.c index f5241fb77..8135c0575 100644 --- a/src/lv_core/lv_style.c +++ b/src/lv_core/lv_style.c @@ -7,6 +7,7 @@ * INCLUDES *********************/ #include "lv_obj.h" +#include "../lv_core/lv_debug.h" #include "../lv_misc/lv_mem.h" #include "../lv_misc/lv_anim.h" @@ -287,7 +288,7 @@ void lv_style_anim_init(lv_anim_t * a) lv_style_anim_dsc_t * dsc; dsc = lv_mem_alloc(sizeof(lv_style_anim_dsc_t)); - lv_mem_assert(dsc); + LV_ASSERT_NO_MEM(dsc); if(dsc == NULL) return; dsc->ready_cb = NULL; dsc->style_anim = NULL; diff --git a/src/lv_draw/lv_draw.c b/src/lv_draw/lv_draw.c index 85a1f7a39..6fb753d88 100644 --- a/src/lv_draw/lv_draw.c +++ b/src/lv_draw/lv_draw.c @@ -10,6 +10,7 @@ #include #include #include "lv_draw.h" +#include "../lv_core/lv_debug.h" #include "../lv_misc/lv_math.h" #include "../lv_misc/lv_log.h" #include "../lv_misc/lv_math.h" @@ -60,12 +61,12 @@ void * lv_draw_get_buf(uint32_t size) if(LV_GC_ROOT(_lv_draw_buf) == NULL) { LV_GC_ROOT(_lv_draw_buf) = lv_mem_alloc(size); - lv_mem_assert(LV_GC_ROOT(_lv_draw_buf)); + LV_ASSERT_NO_MEM(LV_GC_ROOT(_lv_draw_buf)); return LV_GC_ROOT(_lv_draw_buf); } LV_GC_ROOT(_lv_draw_buf) = lv_mem_realloc(LV_GC_ROOT(_lv_draw_buf), size); - lv_mem_assert(LV_GC_ROOT(_lv_draw_buf)); + LV_ASSERT_NO_MEM(LV_GC_ROOT(_lv_draw_buf)); return LV_GC_ROOT(_lv_draw_buf); } diff --git a/src/lv_draw/lv_img_cache.c b/src/lv_draw/lv_img_cache.c index eab900c8e..ba0248402 100644 --- a/src/lv_draw/lv_img_cache.c +++ b/src/lv_draw/lv_img_cache.c @@ -6,6 +6,7 @@ /********************* * INCLUDES *********************/ +#include "../lv_core/lv_debug.h" #include "lv_img_cache.h" #include "../lv_hal/lv_hal_tick.h" #include "../lv_misc/lv_gc.h" @@ -152,7 +153,7 @@ void lv_img_cache_set_size(uint16_t new_entry_cnt) /*Reallocate the cache*/ LV_GC_ROOT(_lv_img_cache_array) = lv_mem_alloc(sizeof(lv_img_cache_entry_t) * new_entry_cnt); - lv_mem_assert(LV_GC_ROOT(_lv_img_cache_array)); + LV_ASSERT_NO_MEM(LV_GC_ROOT(_lv_img_cache_array)); if(LV_GC_ROOT(_lv_img_cache_array) == NULL) { entry_cnt = 0; return; diff --git a/src/lv_draw/lv_img_decoder.c b/src/lv_draw/lv_img_decoder.c index cd53d3934..8c40939d8 100644 --- a/src/lv_draw/lv_img_decoder.c +++ b/src/lv_draw/lv_img_decoder.c @@ -7,6 +7,7 @@ * INCLUDES *********************/ #include "lv_img_decoder.h" +#include "../lv_core/lv_debug.h" #include "../lv_draw/lv_draw_img.h" #include "../lv_misc/lv_ll.h" #include "../lv_misc/lv_color.h" @@ -69,7 +70,7 @@ void lv_img_decoder_init(void) decoder = lv_img_decoder_create(); if(decoder == NULL) { LV_LOG_WARN("lv_img_decoder_init: out of memory"); - lv_mem_assert(decoder); + LV_ASSERT_NO_MEM(decoder); return; } @@ -187,7 +188,7 @@ lv_img_decoder_t * lv_img_decoder_create(void) { lv_img_decoder_t * decoder; decoder = lv_ll_ins_head(&LV_GC_ROOT(_lv_img_defoder_ll)); - lv_mem_assert(decoder); + LV_ASSERT_NO_MEM(decoder); if(decoder == NULL) return NULL; memset(decoder, 0, sizeof(lv_img_decoder_t)); @@ -322,7 +323,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder dsc->user_data = lv_mem_alloc(sizeof(lv_img_decoder_built_in_data_t)); if(dsc->user_data == NULL) { LV_LOG_ERROR("img_decoder_built_in_open: out of memory"); - lv_mem_assert(dsc->user_data); + LV_ASSERT_NO_MEM(dsc->user_data); } memset(dsc->user_data, 0, sizeof(lv_img_decoder_built_in_data_t)); } @@ -331,7 +332,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder user_data->f = lv_mem_alloc(sizeof(f)); if(user_data->f == NULL) { LV_LOG_ERROR("img_decoder_built_in_open: out of memory"); - lv_mem_assert(user_data->f); + LV_ASSERT_NO_MEM(user_data->f); } memcpy(user_data->f, &f, sizeof(f)); @@ -369,7 +370,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder dsc->user_data = lv_mem_alloc(sizeof(lv_img_decoder_built_in_data_t)); if(dsc->user_data == NULL) { LV_LOG_ERROR("img_decoder_built_in_open: out of memory"); - lv_mem_assert(dsc->user_data); + LV_ASSERT_NO_MEM(dsc->user_data); } memset(dsc->user_data, 0, sizeof(lv_img_decoder_built_in_data_t)); } @@ -380,7 +381,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder if(user_data->palette == NULL || user_data->opa == NULL) { LV_LOG_ERROR("img_decoder_built_in_open: out of memory"); #if LV_USE_FILESYSTEM - lv_mem_assert(user_data->f); + LV_ASSERT_NO_MEM(user_data->f); #endif } diff --git a/src/lv_font/lv_font_fmt_txt.c b/src/lv_font/lv_font_fmt_txt.c index c52c4490a..63ea75c8e 100644 --- a/src/lv_font/lv_font_fmt_txt.c +++ b/src/lv_font/lv_font_fmt_txt.c @@ -8,6 +8,7 @@ *********************/ #include "lv_font.h" #include "lv_font_fmt_txt.h" +#include "../lv_core/lv_debug.h" #include "../lv_draw/lv_draw.h" #include "../lv_misc/lv_types.h" #include "../lv_misc/lv_log.h" @@ -100,7 +101,7 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic if(lv_mem_get_size(buf) < buf_size) { buf = lv_mem_realloc(buf, buf_size); - lv_mem_assert(buf); + LV_ASSERT_NO_MEM(buf); if(buf == NULL) return NULL; } diff --git a/src/lv_hal/lv_hal_disp.c b/src/lv_hal/lv_hal_disp.c index 9e97e6b37..bdfebe66d 100644 --- a/src/lv_hal/lv_hal_disp.c +++ b/src/lv_hal/lv_hal_disp.c @@ -12,6 +12,7 @@ #include #include #include "lv_hal.h" +#include "../lv_core/lv_debug.h" #include "../lv_misc/lv_mem.h" #include "../lv_core/lv_obj.h" #include "../lv_core/lv_refr.h" @@ -118,7 +119,7 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver) { lv_disp_t * disp = lv_ll_ins_head(&LV_GC_ROOT(_lv_disp_ll)); if(!disp) { - lv_mem_assert(disp); + LV_ASSERT_NO_MEM(disp); return NULL; } @@ -147,7 +148,7 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver) /*Create a refresh task*/ disp->refr_task = lv_task_create(lv_disp_refr_task, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, disp); - lv_mem_assert(disp->refr_task); + LV_ASSERT_NO_MEM(disp->refr_task); if(disp->refr_task == NULL) return NULL; lv_task_ready(disp->refr_task); /*Be sure the screen will be refreshed immediately on start up*/ diff --git a/src/lv_hal/lv_hal_indev.c b/src/lv_hal/lv_hal_indev.c index 112734117..8d2a70b9a 100644 --- a/src/lv_hal/lv_hal_indev.c +++ b/src/lv_hal/lv_hal_indev.c @@ -8,6 +8,7 @@ /********************* * INCLUDES *********************/ +#include "../lv_core/lv_debug.h" #include "../lv_hal/lv_hal_indev.h" #include "../lv_core/lv_indev.h" #include "../lv_misc/lv_mem.h" @@ -77,7 +78,7 @@ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t * driver) lv_indev_t * indev = lv_ll_ins_head(&LV_GC_ROOT(_lv_indev_ll)); if(!indev) { - lv_mem_assert(indev); + LV_ASSERT_NO_MEM(indev); return NULL; } diff --git a/src/lv_misc/lv_anim.c b/src/lv_misc/lv_anim.c index 5a50165b8..c66fc5166 100644 --- a/src/lv_misc/lv_anim.c +++ b/src/lv_misc/lv_anim.c @@ -11,6 +11,7 @@ #if LV_USE_ANIMATION #include #include +#include "../lv_core/lv_debug.h" #include "../lv_hal/lv_hal_tick.h" #include "lv_task.h" #include "lv_math.h" @@ -89,7 +90,7 @@ void lv_anim_create(lv_anim_t * a) /*Add the new animation to the animation linked list*/ lv_anim_t * new_anim = lv_ll_ins_head(&LV_GC_ROOT(_lv_anim_ll)); - lv_mem_assert(new_anim); + LV_ASSERT_NO_MEM(new_anim); if(new_anim == NULL) return; /*Initialize the animation descriptor*/ diff --git a/src/lv_misc/lv_fs.c b/src/lv_misc/lv_fs.c index ddf8f3810..e06e41645 100644 --- a/src/lv_misc/lv_fs.c +++ b/src/lv_misc/lv_fs.c @@ -9,6 +9,7 @@ #include "lv_fs.h" #if LV_USE_FILESYSTEM +#include "../lv_core/lv_debug.h" #include "lv_ll.h" #include #include "lv_gc.h" @@ -107,7 +108,7 @@ lv_fs_res_t lv_fs_open(lv_fs_file_t * file_p, const char * path, lv_fs_mode_t mo } file_p->file_d = lv_mem_alloc(file_p->drv->file_size); - lv_mem_assert(file_p->file_d); + LV_ASSERT_NO_MEM(file_p->file_d); if(file_p->file_d == NULL) { file_p->drv = NULL; return LV_FS_RES_OUT_OF_MEM; /* Out of memory */ @@ -367,7 +368,7 @@ lv_fs_res_t lv_fs_dir_open(lv_fs_dir_t * rddir_p, const char * path) } rddir_p->dir_d = lv_mem_alloc(rddir_p->drv->rddir_size); - lv_mem_assert(rddir_p->dir_d); + LV_ASSERT_NO_MEM(rddir_p->dir_d); if(rddir_p->dir_d == NULL) { rddir_p->dir_d = NULL; return LV_FS_RES_OUT_OF_MEM; /* Out of memory */ @@ -486,7 +487,7 @@ void lv_fs_drv_register(lv_fs_drv_t * drv_p) /*Save the new driver*/ lv_fs_drv_t * new_drv; new_drv = lv_ll_ins_head(&LV_GC_ROOT(_lv_drv_ll)); - lv_mem_assert(new_drv); + LV_ASSERT_NO_MEM(new_drv); if(new_drv == NULL) return; memcpy(new_drv, drv_p, sizeof(lv_fs_drv_t)); diff --git a/src/lv_misc/lv_mem.h b/src/lv_misc/lv_mem.h index 81a3e7a2f..2353122ee 100644 --- a/src/lv_misc/lv_mem.h +++ b/src/lv_misc/lv_mem.h @@ -110,27 +110,6 @@ uint32_t lv_mem_get_size(const void * data); * MACROS **********************/ -/** - * Halt on NULL pointer - * p pointer to a memory - */ -#if LV_USE_LOG == 0 -#define lv_mem_assert(p) \ - { \ - if(p == NULL) \ - while(1) \ - ; \ - } -#else -#define lv_mem_assert(p) \ - { \ - if(p == NULL) { \ - LV_LOG_ERROR("Out of memory!"); \ - while(1) \ - ; \ - } \ - } -#endif #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/lv_misc/lv_task.c b/src/lv_misc/lv_task.c index 296fa8f91..e5f4437bf 100644 --- a/src/lv_misc/lv_task.c +++ b/src/lv_misc/lv_task.c @@ -9,6 +9,7 @@ *********************/ #include #include "lv_task.h" +#include "../lv_core/lv_debug.h" #include "../lv_hal/lv_hal_tick.h" #include "lv_gc.h" @@ -173,7 +174,7 @@ lv_task_t * lv_task_create_basic(void) /*It's the first task*/ if(NULL == tmp) { new_task = lv_ll_ins_head(&LV_GC_ROOT(_lv_task_ll)); - lv_mem_assert(new_task); + LV_ASSERT_NO_MEM(new_task); if(new_task == NULL) return NULL; } /*Insert the new task to proper place according to its priority*/ @@ -181,7 +182,7 @@ lv_task_t * lv_task_create_basic(void) do { if(tmp->prio <= DEF_PRIO) { new_task = lv_ll_ins_prev(&LV_GC_ROOT(_lv_task_ll), tmp); - lv_mem_assert(new_task); + LV_ASSERT_NO_MEM(new_task); if(new_task == NULL) return NULL; break; } @@ -191,7 +192,7 @@ lv_task_t * lv_task_create_basic(void) /*Only too high priority tasks were found. Add the task to the end*/ if(tmp == NULL) { new_task = lv_ll_ins_tail(&LV_GC_ROOT(_lv_task_ll)); - lv_mem_assert(new_task); + LV_ASSERT_NO_MEM(new_task); if(new_task == NULL) return NULL; } } @@ -223,7 +224,7 @@ lv_task_t * lv_task_create_basic(void) lv_task_t * lv_task_create(lv_task_cb_t task_cb, uint32_t period, lv_task_prio_t prio, void * user_data) { lv_task_t * new_task = lv_task_create_basic(); - lv_mem_assert(new_task); + LV_ASSERT_NO_MEM(new_task); if(new_task == NULL) return NULL; lv_task_set_cb(new_task, task_cb); diff --git a/src/lv_objx/lv_arc.c b/src/lv_objx/lv_arc.c index 7db5fb5e4..e18ebcf8a 100644 --- a/src/lv_objx/lv_arc.c +++ b/src/lv_objx/lv_arc.c @@ -9,6 +9,7 @@ #include "lv_arc.h" #if LV_USE_ARC != 0 +#include "../lv_core/lv_debug.h" #include "../lv_misc/lv_math.h" #include "../lv_draw/lv_draw_arc.h" #include "../lv_themes/lv_theme.h" @@ -54,12 +55,12 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor of arc*/ lv_obj_t * new_arc = lv_obj_create(par, copy); - lv_mem_assert(new_arc); + LV_ASSERT_NO_MEM(new_arc); if(new_arc == NULL) return NULL; /*Allocate the arc type specific extended data*/ lv_arc_ext_t * ext = lv_obj_allocate_ext_attr(new_arc, sizeof(lv_arc_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_arc); diff --git a/src/lv_objx/lv_bar.c b/src/lv_objx/lv_bar.c index 6b6ebb349..bd334d49b 100644 --- a/src/lv_objx/lv_bar.c +++ b/src/lv_objx/lv_bar.c @@ -11,6 +11,7 @@ #include "lv_bar.h" #if LV_USE_BAR != 0 +#include "../lv_core/lv_debug.h" #include "../lv_draw/lv_draw.h" #include "../lv_themes/lv_theme.h" #include "../lv_misc/lv_anim.h" @@ -61,7 +62,7 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor basic object*/ lv_obj_t * new_bar = lv_obj_create(par, copy); - lv_mem_assert(new_bar); + LV_ASSERT_NO_MEM(new_bar); if(new_bar == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_bar); @@ -69,7 +70,7 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the object type specific extended data*/ lv_bar_ext_t * ext = lv_obj_allocate_ext_attr(new_bar, sizeof(lv_bar_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; ext->min_value = 0; diff --git a/src/lv_objx/lv_btn.c b/src/lv_objx/lv_btn.c index 7ab3e5b25..c31628787 100644 --- a/src/lv_objx/lv_btn.c +++ b/src/lv_objx/lv_btn.c @@ -12,6 +12,7 @@ #include #include "../lv_core/lv_group.h" +#include "../lv_core/lv_debug.h" #include "../lv_draw/lv_draw.h" #include "../lv_themes/lv_theme.h" #include "../lv_misc/lv_area.h" @@ -76,7 +77,7 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy) lv_obj_t * new_btn; new_btn = lv_cont_create(par, copy); - lv_mem_assert(new_btn); + LV_ASSERT_NO_MEM(new_btn); if(new_btn == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_btn); @@ -84,7 +85,7 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the extended data*/ lv_btn_ext_t * ext = lv_obj_allocate_ext_attr(new_btn, sizeof(lv_btn_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; ext->state = LV_BTN_STATE_REL; diff --git a/src/lv_objx/lv_btnm.c b/src/lv_objx/lv_btnm.c index cf3b882ae..c567b171b 100644 --- a/src/lv_objx/lv_btnm.c +++ b/src/lv_objx/lv_btnm.c @@ -9,6 +9,7 @@ #include "lv_btnm.h" #if LV_USE_BTNM != 0 +#include "../lv_core/lv_debug.h" #include "../lv_core/lv_group.h" #include "../lv_draw/lv_draw.h" #include "../lv_core/lv_refr.h" @@ -70,14 +71,14 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor object*/ lv_obj_t * new_btnm = lv_obj_create(par, copy); - lv_mem_assert(new_btnm); + LV_ASSERT_NO_MEM(new_btnm); if(new_btnm == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_btnm); /*Allocate the object type specific extended data*/ lv_btnm_ext_t * ext = lv_obj_allocate_ext_attr(new_btnm, sizeof(lv_btnm_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; ext->btn_cnt = 0; @@ -938,9 +939,9 @@ static void allocate_btn_areas_and_controls(const lv_obj_t * btnm, const char ** } ext->button_areas = lv_mem_alloc(sizeof(lv_area_t) * btn_cnt); - lv_mem_assert(ext->button_areas); + LV_ASSERT_NO_MEM(ext->button_areas); ext->ctrl_bits = lv_mem_alloc(sizeof(lv_btnm_ctrl_t) * btn_cnt); - lv_mem_assert(ext->ctrl_bits); + LV_ASSERT_NO_MEM(ext->ctrl_bits); if(ext->button_areas == NULL || ext->ctrl_bits == NULL) btn_cnt = 0; memset(ext->ctrl_bits, 0, sizeof(lv_btnm_ctrl_t) * btn_cnt); diff --git a/src/lv_objx/lv_calendar.c b/src/lv_objx/lv_calendar.c index 36baea3dc..c22346040 100644 --- a/src/lv_objx/lv_calendar.c +++ b/src/lv_objx/lv_calendar.c @@ -9,6 +9,7 @@ #include "lv_calendar.h" #if LV_USE_CALENDAR != 0 +#include "../lv_core/lv_debug.h" #include "../lv_draw/lv_draw.h" #include "../lv_hal/lv_hal_indev.h" #include "../lv_misc/lv_utils.h" @@ -77,12 +78,12 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor of calendar*/ lv_obj_t * new_calendar = lv_obj_create(par, copy); - lv_mem_assert(new_calendar); + LV_ASSERT_NO_MEM(new_calendar); if(new_calendar == NULL) return NULL; /*Allocate the calendar type specific extended data*/ lv_calendar_ext_t * ext = lv_obj_allocate_ext_attr(new_calendar, sizeof(lv_calendar_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_calendar); if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_calendar); diff --git a/src/lv_objx/lv_canvas.c b/src/lv_objx/lv_canvas.c index da08521a8..ac7863356 100644 --- a/src/lv_objx/lv_canvas.c +++ b/src/lv_objx/lv_canvas.c @@ -8,6 +8,7 @@ *********************/ #include #include "lv_canvas.h" +#include "../lv_core/lv_debug.h" #include "../lv_misc/lv_math.h" #include "../lv_draw/lv_draw.h" #include "../lv_core/lv_refr.h" @@ -53,12 +54,12 @@ lv_obj_t * lv_canvas_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor of canvas*/ lv_obj_t * new_canvas = lv_img_create(par, copy); - lv_mem_assert(new_canvas); + LV_ASSERT_NO_MEM(new_canvas); if(new_canvas == NULL) return NULL; /*Allocate the canvas type specific extended data*/ lv_canvas_ext_t * ext = lv_obj_allocate_ext_attr(new_canvas, sizeof(lv_canvas_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_canvas); if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_canvas); diff --git a/src/lv_objx/lv_cb.c b/src/lv_objx/lv_cb.c index ef76f2242..5d5e4850b 100644 --- a/src/lv_objx/lv_cb.c +++ b/src/lv_objx/lv_cb.c @@ -9,6 +9,7 @@ #include "lv_cb.h" #if LV_USE_CB != 0 +#include "../lv_core/lv_debug.h" #include "../lv_core/lv_group.h" #include "../lv_themes/lv_theme.h" @@ -55,14 +56,14 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor basic object*/ lv_obj_t * new_cb = lv_btn_create(par, copy); - lv_mem_assert(new_cb); + LV_ASSERT_NO_MEM(new_cb); if(new_cb == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_cb); if(ancestor_bg_design == NULL) ancestor_bg_design = lv_obj_get_design_cb(new_cb); lv_cb_ext_t * ext = lv_obj_allocate_ext_attr(new_cb, sizeof(lv_cb_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; ext->bullet = NULL; diff --git a/src/lv_objx/lv_chart.c b/src/lv_objx/lv_chart.c index 4c1d034e7..ed97c2dfd 100644 --- a/src/lv_objx/lv_chart.c +++ b/src/lv_objx/lv_chart.c @@ -9,6 +9,7 @@ #include "lv_chart.h" #if LV_USE_CHART != 0 +#include "../lv_core/lv_debug.h" #include "../lv_core/lv_refr.h" #include "../lv_draw/lv_draw.h" #include "../lv_themes/lv_theme.h" @@ -86,12 +87,12 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor basic object*/ lv_obj_t * new_chart = lv_obj_create(par, copy); - lv_mem_assert(new_chart); + LV_ASSERT_NO_MEM(new_chart); if(new_chart == NULL) return NULL; /*Allocate the object type specific extended data*/ lv_chart_ext_t * ext = lv_obj_allocate_ext_attr(new_chart, sizeof(lv_chart_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; lv_ll_init(&ext->series_ll, sizeof(lv_chart_series_t)); @@ -174,7 +175,7 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color) { lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); lv_chart_series_t * ser = lv_ll_ins_head(&ext->series_ll); - lv_mem_assert(ser); + LV_ASSERT_NO_MEM(ser); if(ser == NULL) return NULL; lv_coord_t def = LV_CHART_POINT_DEF; @@ -183,7 +184,7 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color) ser->color = color; ser->points = lv_mem_alloc(sizeof(lv_coord_t) * ext->point_cnt); - lv_mem_assert(ser->points); + LV_ASSERT_NO_MEM(ser->points); if(ser->points == NULL) { lv_ll_rem(&ext->series_ll, ser); lv_mem_free(ser); @@ -297,7 +298,7 @@ void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt) { if(ser->start_point != 0) { lv_coord_t * new_points = lv_mem_alloc(sizeof(lv_coord_t) * point_cnt); - lv_mem_assert(new_points); + LV_ASSERT_NO_MEM(new_points); if(new_points == NULL) return; if(point_cnt >= point_cnt_old) { @@ -320,7 +321,7 @@ void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt) ser->points = new_points; } else { ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * point_cnt); - lv_mem_assert(ser->points); + LV_ASSERT_NO_MEM(ser->points); if(ser->points == NULL) return; /*Initialize the new points*/ if(point_cnt > point_cnt_old) { diff --git a/src/lv_objx/lv_cont.c b/src/lv_objx/lv_cont.c index 2ff4059f0..b31b9619c 100644 --- a/src/lv_objx/lv_cont.c +++ b/src/lv_objx/lv_cont.c @@ -14,6 +14,7 @@ #include #include +#include "../lv_core/lv_debug.h" #include "../lv_draw/lv_draw.h" #include "../lv_draw/lv_draw_basic.h" #include "../lv_themes/lv_theme.h" @@ -67,7 +68,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy) /*Create a basic object*/ lv_obj_t * new_cont = lv_obj_create(par, copy); - lv_mem_assert(new_cont); + LV_ASSERT_NO_MEM(new_cont); if(new_cont == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_cont); @@ -76,7 +77,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy) lv_cont_ext_t * ext = lv_obj_get_ext_attr(new_cont); if(ext == NULL) return NULL; - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); ext->fit_left = LV_FIT_NONE; ext->fit_right = LV_FIT_NONE; ext->fit_top = LV_FIT_NONE; diff --git a/src/lv_objx/lv_ddlist.c b/src/lv_objx/lv_ddlist.c index faf21752b..361bc5c59 100644 --- a/src/lv_objx/lv_ddlist.c +++ b/src/lv_objx/lv_ddlist.c @@ -9,6 +9,7 @@ #include "lv_ddlist.h" #if LV_USE_DDLIST != 0 +#include "../lv_core/lv_debug.h" #include "../lv_draw/lv_draw.h" #include "../lv_core/lv_group.h" #include "../lv_core/lv_indev.h" @@ -74,7 +75,7 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor drop down list*/ lv_obj_t * new_ddlist = lv_page_create(par, copy); - lv_mem_assert(new_ddlist); + LV_ASSERT_NO_MEM(new_ddlist); if(new_ddlist == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_ddlist); @@ -83,7 +84,7 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the drop down list type specific extended data*/ lv_ddlist_ext_t * ext = lv_obj_allocate_ext_attr(new_ddlist, sizeof(lv_ddlist_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; /*Initialize the allocated 'ext' */ diff --git a/src/lv_objx/lv_gauge.c b/src/lv_objx/lv_gauge.c index 5703b910f..90a3c2f34 100644 --- a/src/lv_objx/lv_gauge.c +++ b/src/lv_objx/lv_gauge.c @@ -9,6 +9,7 @@ #include "lv_gauge.h" #if LV_USE_GAUGE != 0 +#include "../lv_core/lv_debug.h" #include "../lv_draw/lv_draw.h" #include "../lv_themes/lv_theme.h" #include "../lv_misc/lv_txt.h" @@ -65,12 +66,12 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor gauge*/ lv_obj_t * new_gauge = lv_lmeter_create(par, copy); - lv_mem_assert(new_gauge); + LV_ASSERT_NO_MEM(new_gauge); if(new_gauge == NULL) return NULL; /*Allocate the gauge type specific extended data*/ lv_gauge_ext_t * ext = lv_obj_allocate_ext_attr(new_gauge, sizeof(lv_gauge_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; /*Initialize the allocated 'ext' */ @@ -140,7 +141,7 @@ void lv_gauge_set_needle_count(lv_obj_t * gauge, uint8_t needle_cnt, const lv_co } ext->values = lv_mem_realloc(ext->values, needle_cnt * sizeof(int16_t)); - lv_mem_assert(ext->values); + LV_ASSERT_NO_MEM(ext->values); if(ext->values == NULL) return; int16_t min = lv_gauge_get_min_value(gauge); diff --git a/src/lv_objx/lv_img.c b/src/lv_objx/lv_img.c index 3b034d392..32e0d88a9 100644 --- a/src/lv_objx/lv_img.c +++ b/src/lv_objx/lv_img.c @@ -14,6 +14,7 @@ #error "lv_img: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1) " #endif +#include "../lv_core/lv_debug.h" #include "../lv_themes/lv_theme.h" #include "../lv_draw/lv_img_decoder.h" #include "../lv_misc/lv_fs.h" @@ -61,14 +62,14 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy) /*Create a basic object*/ new_img = lv_obj_create(par, copy); - lv_mem_assert(new_img); + LV_ASSERT_NO_MEM(new_img); if(new_img == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_img); /*Extend the basic object to image object*/ lv_img_ext_t * ext = lv_obj_allocate_ext_attr(new_img, sizeof(lv_img_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; ext->src = NULL; @@ -164,7 +165,7 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img) lv_mem_free(ext->src); } char * new_str = lv_mem_alloc(strlen(src_img) + 1); - lv_mem_assert(new_str); + LV_ASSERT_NO_MEM(new_str); if(new_str == NULL) return; strcpy(new_str, src_img); ext->src = new_str; diff --git a/src/lv_objx/lv_imgbtn.c b/src/lv_objx/lv_imgbtn.c index b2e5cf6d8..65fe67957 100644 --- a/src/lv_objx/lv_imgbtn.c +++ b/src/lv_objx/lv_imgbtn.c @@ -6,7 +6,10 @@ /********************* * INCLUDES *********************/ + +#include "../lv_core/lv_debug.h" #include "lv_imgbtn.h" + #if LV_USE_IMGBTN != 0 /********************* @@ -51,12 +54,12 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor of image button*/ lv_obj_t * new_imgbtn = lv_btn_create(par, copy); - lv_mem_assert(new_imgbtn); + LV_ASSERT_NO_MEM(new_imgbtn); if(new_imgbtn == NULL) return NULL; /*Allocate the image button type specific extended data*/ lv_imgbtn_ext_t * ext = lv_obj_allocate_ext_attr(new_imgbtn, sizeof(lv_imgbtn_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_imgbtn); if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_imgbtn); diff --git a/src/lv_objx/lv_kb.c b/src/lv_objx/lv_kb.c index 09a3e561d..ed48d58b7 100644 --- a/src/lv_objx/lv_kb.c +++ b/src/lv_objx/lv_kb.c @@ -10,8 +10,9 @@ #include "lv_kb.h" #if LV_USE_KB != 0 -#include "lv_ta.h" +#include "../lv_core/lv_debug.h" #include "../lv_themes/lv_theme.h" +#include "lv_ta.h" /********************* * DEFINES @@ -97,14 +98,14 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor of keyboard*/ lv_obj_t * new_kb = lv_btnm_create(par, copy); - lv_mem_assert(new_kb); + LV_ASSERT_NO_MEM(new_kb); if(new_kb == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_kb); /*Allocate the keyboard type specific extended data*/ lv_kb_ext_t * ext = lv_obj_allocate_ext_attr(new_kb, sizeof(lv_kb_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; /*Initialize the allocated 'ext' */ diff --git a/src/lv_objx/lv_label.c b/src/lv_objx/lv_label.c index a6cff45f2..ded47a051 100644 --- a/src/lv_objx/lv_label.c +++ b/src/lv_objx/lv_label.c @@ -10,6 +10,7 @@ #if LV_USE_LABEL != 0 #include "../lv_core/lv_obj.h" +#include "../lv_core/lv_debug.h" #include "../lv_core/lv_group.h" #include "../lv_misc/lv_color.h" #include "../lv_misc/lv_math.h" @@ -18,6 +19,8 @@ /********************* * DEFINES *********************/ +#define __LV_OBJX_TYPE "lv_label" + /*Test configurations*/ #ifndef LV_LABEL_DEF_SCROLL_SPEED #define LV_LABEL_DEF_SCROLL_SPEED (25) @@ -73,7 +76,7 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy) /*Create a basic object*/ lv_obj_t * new_label = lv_obj_create(par, copy); - lv_mem_assert(new_label); + LV_ASSERT_NO_MEM(new_label); if(new_label == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_label); @@ -82,7 +85,7 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy) lv_obj_allocate_ext_attr(new_label, sizeof(lv_label_ext_t)); lv_label_ext_t * ext = lv_obj_get_ext_attr(new_label); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; ext->text = NULL; @@ -136,7 +139,7 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy) /*In DOT mode save the text byte-to-byte because a '\0' can be in the middle*/ if(copy_ext->long_mode == LV_LABEL_LONG_DOT) { ext->text = lv_mem_realloc(ext->text, lv_mem_get_size(copy_ext->text)); - lv_mem_assert(ext->text); + LV_ASSERT_NO_MEM(ext->text); if(ext->text == NULL) return NULL; memcpy(ext->text, copy_ext->text, lv_mem_get_size(copy_ext->text)); } @@ -170,6 +173,10 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy) */ void lv_label_set_text(lv_obj_t * label, const char * text) { + LV_ASSERT_NULL(label); + LV_ASSERT_OBJ_NOT_EXISTS(label); + LV_ASSERT_OBJ_TYPE_ERROR(label, __LV_OBJX_TYPE); + lv_obj_invalidate(label); lv_label_ext_t * ext = lv_obj_get_ext_attr(label); @@ -183,7 +190,7 @@ void lv_label_set_text(lv_obj_t * label, const char * text) if(ext->text == text) { /*If set its own text then reallocate it (maybe its size changed)*/ ext->text = lv_mem_realloc(ext->text, strlen(ext->text) + 1); - lv_mem_assert(ext->text); + LV_ASSERT_NO_MEM(ext->text); if(ext->text == NULL) return; } else { /*Allocate space for the new text*/ @@ -194,7 +201,7 @@ void lv_label_set_text(lv_obj_t * label, const char * text) } ext->text = lv_mem_alloc(len); - lv_mem_assert(ext->text); + LV_ASSERT_NO_MEM(ext->text); if(ext->text == NULL) return; strcpy(ext->text, text); @@ -237,7 +244,7 @@ void lv_label_set_text_fmt(lv_obj_t * label, const char * fmt, ...) ext->text = lv_mem_alloc(len+1); - lv_mem_assert(ext->text); + LV_ASSERT_NO_MEM(ext->text); if(ext->text == NULL) return; ext->text[len-1] = 0; /* Ensure NULL termination */ @@ -274,7 +281,7 @@ void lv_label_set_array_text(lv_obj_t * label, const char * array, uint16_t size ext->text = NULL; } ext->text = lv_mem_alloc(size + 1); - lv_mem_assert(ext->text); + LV_ASSERT_NO_MEM(ext->text); if(ext->text == NULL) return; memcpy(ext->text, array, size); @@ -807,7 +814,7 @@ void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt) uint32_t ins_len = strlen(txt); uint32_t new_len = ins_len + old_len; ext->text = lv_mem_realloc(ext->text, new_len + 1); - lv_mem_assert(ext->text); + LV_ASSERT_NO_MEM(ext->text); if(ext->text == NULL) return; if(pos == LV_LABEL_POS_LAST) { diff --git a/src/lv_objx/lv_led.c b/src/lv_objx/lv_led.c index c991b518b..1e06cc640 100644 --- a/src/lv_objx/lv_led.c +++ b/src/lv_objx/lv_led.c @@ -9,6 +9,7 @@ #include "lv_led.h" #if LV_USE_LED != 0 +#include "../lv_core/lv_debug.h" #include "../lv_themes/lv_theme.h" #include "../lv_draw/lv_draw.h" @@ -56,7 +57,7 @@ lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor basic object*/ lv_obj_t * new_led = lv_obj_create(par, copy); - lv_mem_assert(new_led); + LV_ASSERT_NO_MEM(new_led); if(new_led == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_led); @@ -64,7 +65,7 @@ lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the object type specific extended data*/ lv_led_ext_t * ext = lv_obj_allocate_ext_attr(new_led, sizeof(lv_led_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; ext->bright = LV_LED_BRIGHT_ON; diff --git a/src/lv_objx/lv_line.c b/src/lv_objx/lv_line.c index 3831449a0..b235077a9 100644 --- a/src/lv_objx/lv_line.c +++ b/src/lv_objx/lv_line.c @@ -9,6 +9,7 @@ #include "lv_line.h" #if LV_USE_LINE != 0 +#include "../lv_core/lv_debug.h" #include "../lv_draw/lv_draw.h" #include "../lv_misc/lv_math.h" #include @@ -53,14 +54,14 @@ lv_obj_t * lv_line_create(lv_obj_t * par, const lv_obj_t * copy) /*Create a basic object*/ lv_obj_t * new_line = lv_obj_create(par, copy); - lv_mem_assert(new_line); + LV_ASSERT_NO_MEM(new_line); if(new_line == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_line); /*Extend the basic object to line object*/ lv_line_ext_t * ext = lv_obj_allocate_ext_attr(new_line, sizeof(lv_line_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; ext->point_num = 0; diff --git a/src/lv_objx/lv_list.c b/src/lv_objx/lv_list.c index 977826e74..793a199ed 100644 --- a/src/lv_objx/lv_list.c +++ b/src/lv_objx/lv_list.c @@ -9,6 +9,7 @@ #include "lv_list.h" #if LV_USE_LIST != 0 +#include "../lv_core/lv_debug.h" #include "../lv_core/lv_group.h" #include "../lv_themes/lv_theme.h" #include "../lv_misc/lv_anim.h" @@ -69,13 +70,13 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor basic object*/ lv_obj_t * new_list = lv_page_create(par, copy); - lv_mem_assert(new_list); + LV_ASSERT_NO_MEM(new_list); if(new_list == NULL) return NULL; if(ancestor_page_signal == NULL) ancestor_page_signal = lv_obj_get_signal_cb(new_list); lv_list_ext_t * ext = lv_obj_allocate_ext_attr(new_list, sizeof(lv_list_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; ext->style_img = NULL; diff --git a/src/lv_objx/lv_lmeter.c b/src/lv_objx/lv_lmeter.c index 78f7a8e61..ca0f8d2e6 100644 --- a/src/lv_objx/lv_lmeter.c +++ b/src/lv_objx/lv_lmeter.c @@ -9,6 +9,7 @@ #include "lv_lmeter.h" #if LV_USE_LMETER != 0 +#include "../lv_core/lv_debug.h" #include "../lv_draw/lv_draw.h" #include "../lv_themes/lv_theme.h" #include "../lv_core/lv_group.h" @@ -57,14 +58,14 @@ lv_obj_t * lv_lmeter_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor of line meter*/ lv_obj_t * new_lmeter = lv_obj_create(par, copy); - lv_mem_assert(new_lmeter); + LV_ASSERT_NO_MEM(new_lmeter); if(new_lmeter == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_lmeter); /*Allocate the line meter type specific extended data*/ lv_lmeter_ext_t * ext = lv_obj_allocate_ext_attr(new_lmeter, sizeof(lv_lmeter_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; /*Initialize the allocated 'ext' */ diff --git a/src/lv_objx/lv_mbox.c b/src/lv_objx/lv_mbox.c index 9a5fa1dd7..e0b80b427 100644 --- a/src/lv_objx/lv_mbox.c +++ b/src/lv_objx/lv_mbox.c @@ -9,6 +9,7 @@ #include "lv_mbox.h" #if LV_USE_MBOX != 0 +#include "../lv_core/lv_debug.h" #include "../lv_core/lv_group.h" #include "../lv_themes/lv_theme.h" #include "../lv_misc/lv_anim.h" @@ -68,14 +69,14 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor message box*/ lv_obj_t * new_mbox = lv_cont_create(par, copy); - lv_mem_assert(new_mbox); + LV_ASSERT_NO_MEM(new_mbox); if(new_mbox == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_mbox); /*Allocate the message box type specific extended data*/ lv_mbox_ext_t * ext = lv_obj_allocate_ext_attr(new_mbox, sizeof(lv_mbox_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; ext->text = NULL; diff --git a/src/lv_objx/lv_objx_templ.c b/src/lv_objx/lv_objx_templ.c index b5c1b258e..850be2ddd 100644 --- a/src/lv_objx/lv_objx_templ.c +++ b/src/lv_objx/lv_objx_templ.c @@ -15,6 +15,7 @@ /********************* * INCLUDES *********************/ +#include "../lv_core/lv_debug.h" //#include "lv_templ.h" /*TODO uncomment this*/ #if defined(LV_USE_TEMPL) && LV_USE_TEMPL != 0 diff --git a/src/lv_objx/lv_page.c b/src/lv_objx/lv_page.c index e6c315363..b2684536b 100644 --- a/src/lv_objx/lv_page.c +++ b/src/lv_objx/lv_page.c @@ -9,6 +9,7 @@ #include "../lv_objx/lv_page.h" #if LV_USE_PAGE != 0 +#include "../lv_core/lv_debug.h" #include "../lv_core/lv_group.h" #include "../lv_draw/lv_draw.h" #include "../lv_themes/lv_theme.h" @@ -77,7 +78,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor object*/ lv_obj_t * new_page = lv_cont_create(par, copy); - lv_mem_assert(new_page); + LV_ASSERT_NO_MEM(new_page); if(new_page == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_page); @@ -85,7 +86,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the object type specific extended data*/ lv_page_ext_t * ext = lv_obj_allocate_ext_attr(new_page, sizeof(lv_page_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; ext->scrl = NULL; diff --git a/src/lv_objx/lv_preload.c b/src/lv_objx/lv_preload.c index eca360813..2a01d999b 100644 --- a/src/lv_objx/lv_preload.c +++ b/src/lv_objx/lv_preload.c @@ -9,6 +9,7 @@ #include "lv_preload.h" #if LV_USE_PRELOAD != 0 +#include "../lv_core/lv_debug.h" #include "../lv_misc/lv_math.h" #include "../lv_draw/lv_draw_rect.h" #include "../lv_draw/lv_draw_arc.h" @@ -66,12 +67,12 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor of pre loader*/ lv_obj_t * new_preload = lv_arc_create(par, copy); - lv_mem_assert(new_preload); + LV_ASSERT_NO_MEM(new_preload); if(new_preload == NULL) return NULL; /*Allocate the pre loader type specific extended data*/ lv_preload_ext_t * ext = lv_obj_allocate_ext_attr(new_preload, sizeof(lv_preload_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_preload); diff --git a/src/lv_objx/lv_roller.c b/src/lv_objx/lv_roller.c index 287d139b1..290e94d9b 100644 --- a/src/lv_objx/lv_roller.c +++ b/src/lv_objx/lv_roller.c @@ -9,6 +9,7 @@ #include "lv_roller.h" #if LV_USE_ROLLER != 0 +#include "../lv_core/lv_debug.h" #include "../lv_draw/lv_draw.h" #include "../lv_core/lv_group.h" #include "../lv_themes/lv_theme.h" @@ -65,7 +66,7 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor of roller*/ lv_obj_t * new_roller = lv_ddlist_create(par, copy); - lv_mem_assert(new_roller); + LV_ASSERT_NO_MEM(new_roller); if(new_roller == NULL) return NULL; if(ancestor_scrl_signal == NULL) ancestor_scrl_signal = lv_obj_get_signal_cb(lv_page_get_scrl(new_roller)); @@ -73,7 +74,7 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the roller type specific extended data*/ lv_roller_ext_t * ext = lv_obj_allocate_ext_attr(new_roller, sizeof(lv_roller_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; ext->ddlist.draw_arrow = 0; /*Do not draw arrow by default*/ @@ -263,8 +264,8 @@ uint16_t lv_roller_get_selected(const lv_obj_t * roller) lv_label_align_t lv_roller_get_align(const lv_obj_t * roller) { lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller); - lv_mem_assert(ext); - lv_mem_assert(ext->ddlist.label); + LV_ASSERT_NO_MEM(ext); + LV_ASSERT_NO_MEM(ext->ddlist.label); return lv_label_get_align(ext->ddlist.label); } diff --git a/src/lv_objx/lv_slider.c b/src/lv_objx/lv_slider.c index 6a067f841..9feba2555 100644 --- a/src/lv_objx/lv_slider.c +++ b/src/lv_objx/lv_slider.c @@ -10,6 +10,7 @@ #include "lv_slider.h" #if LV_USE_SLIDER != 0 +#include "../lv_core/lv_debug.h" #include "../lv_core/lv_group.h" #include "../lv_draw/lv_draw.h" #include "../lv_themes/lv_theme.h" @@ -57,7 +58,7 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor slider*/ lv_obj_t * new_slider = lv_bar_create(par, copy); - lv_mem_assert(new_slider); + LV_ASSERT_NO_MEM(new_slider); if(new_slider == NULL) return NULL; if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_cb(new_slider); @@ -65,7 +66,7 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the slider type specific extended data*/ lv_slider_ext_t * ext = lv_obj_allocate_ext_attr(new_slider, sizeof(lv_slider_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; /*Initialize the allocated 'ext' */ diff --git a/src/lv_objx/lv_spinbox.c b/src/lv_objx/lv_spinbox.c index 4dc544942..f90345935 100644 --- a/src/lv_objx/lv_spinbox.c +++ b/src/lv_objx/lv_spinbox.c @@ -9,6 +9,7 @@ #include "lv_spinbox.h" #if LV_USE_SPINBOX != 0 +#include "../lv_core/lv_debug.h" #include "../lv_themes/lv_theme.h" #include "../lv_misc/lv_math.h" #include "../lv_misc/lv_utils.h" @@ -53,12 +54,12 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor of spinbox*/ lv_obj_t * new_spinbox = lv_ta_create(par, copy); - lv_mem_assert(new_spinbox); + LV_ASSERT_NO_MEM(new_spinbox); if(new_spinbox == NULL) return NULL; /*Allocate the spinbox type specific extended data*/ lv_spinbox_ext_t * ext = lv_obj_allocate_ext_attr(new_spinbox, sizeof(lv_spinbox_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_spinbox); if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_spinbox); diff --git a/src/lv_objx/lv_sw.c b/src/lv_objx/lv_sw.c index 80854b0a0..78d195b1f 100644 --- a/src/lv_objx/lv_sw.c +++ b/src/lv_objx/lv_sw.c @@ -15,6 +15,7 @@ #error "lv_sw: lv_slider is required. Enable it in lv_conf.h (LV_USE_SLIDER 1) " #endif +#include "../lv_core/lv_debug.h" #include "../lv_themes/lv_theme.h" #include "../lv_misc/lv_math.h" @@ -56,14 +57,14 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor of switch*/ lv_obj_t * new_sw = lv_slider_create(par, copy); - lv_mem_assert(new_sw); + LV_ASSERT_NO_MEM(new_sw); if(new_sw == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_sw); /*Allocate the switch type specific extended data*/ lv_sw_ext_t * ext = lv_obj_allocate_ext_attr(new_sw, sizeof(lv_sw_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; /*Initialize the allocated 'ext' */ diff --git a/src/lv_objx/lv_ta.c b/src/lv_objx/lv_ta.c index fa44a105c..53bfb0424 100644 --- a/src/lv_objx/lv_ta.c +++ b/src/lv_objx/lv_ta.c @@ -9,6 +9,7 @@ #include "lv_ta.h" #if LV_USE_TA != 0 #include +#include "../lv_core/lv_debug.h" #include "../lv_core/lv_group.h" #include "../lv_core/lv_refr.h" #include "../lv_draw/lv_draw.h" @@ -85,7 +86,7 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor object*/ lv_obj_t * new_ta = lv_page_create(par, copy); - lv_mem_assert(new_ta); + LV_ASSERT_NO_MEM(new_ta); if(new_ta == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_ta); @@ -95,7 +96,7 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the object type specific extended data*/ lv_ta_ext_t * ext = lv_obj_allocate_ext_attr(new_ta, sizeof(lv_ta_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; ext->cursor.state = 1; @@ -173,7 +174,7 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy) if(copy_ext->pwd_tmp) { uint16_t len = lv_mem_get_size(copy_ext->pwd_tmp); ext->pwd_tmp = lv_mem_alloc(len); - lv_mem_assert(ext->pwd_tmp); + LV_ASSERT_NO_MEM(ext->pwd_tmp); if(ext->pwd_tmp == NULL) return NULL; memcpy(ext->pwd_tmp, copy_ext->pwd_tmp, len); @@ -267,7 +268,7 @@ void lv_ta_add_char(lv_obj_t * ta, uint32_t c) if(ext->pwd_mode != 0) { ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + 2); /*+2: the new char + \0 */ - lv_mem_assert(ext->pwd_tmp); + LV_ASSERT_NO_MEM(ext->pwd_tmp); if(ext->pwd_tmp == NULL) return; lv_txt_ins(ext->pwd_tmp, ext->cursor.pos, (const char *)letter_buf); @@ -348,7 +349,7 @@ void lv_ta_add_text(lv_obj_t * ta, const char * txt) if(ext->pwd_mode != 0) { ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + strlen(txt) + 1); - lv_mem_assert(ext->pwd_tmp); + LV_ASSERT_NO_MEM(ext->pwd_tmp); if(ext->pwd_tmp == NULL) return; lv_txt_ins(ext->pwd_tmp, ext->cursor.pos, txt); @@ -427,7 +428,7 @@ void lv_ta_del_char(lv_obj_t * ta) lv_txt_cut(ext->pwd_tmp, ext->cursor.pos - 1, lv_txt_encoded_size(&label_txt[byte_pos])); ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + 1); - lv_mem_assert(ext->pwd_tmp); + LV_ASSERT_NO_MEM(ext->pwd_tmp); if(ext->pwd_tmp == NULL) return; } @@ -489,7 +490,7 @@ void lv_ta_set_text(lv_obj_t * ta, const char * txt) if(ext->pwd_mode != 0) { ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(txt) + 1); - lv_mem_assert(ext->pwd_tmp); + LV_ASSERT_NO_MEM(ext->pwd_tmp); if(ext->pwd_tmp == NULL) return; strcpy(ext->pwd_tmp, txt); @@ -663,7 +664,7 @@ void lv_ta_set_pwd_mode(lv_obj_t * ta, bool en) char * txt = lv_label_get_text(ext->label); uint16_t len = strlen(txt); ext->pwd_tmp = lv_mem_alloc(len + 1); - lv_mem_assert(ext->pwd_tmp); + LV_ASSERT_NO_MEM(ext->pwd_tmp); if(ext->pwd_tmp == NULL) return; strcpy(ext->pwd_tmp, txt); diff --git a/src/lv_objx/lv_table.c b/src/lv_objx/lv_table.c index ab0e47879..b17739502 100644 --- a/src/lv_objx/lv_table.c +++ b/src/lv_objx/lv_table.c @@ -9,6 +9,7 @@ #include "lv_table.h" #if LV_USE_TABLE != 0 +#include "../lv_core/lv_debug.h" #include "../lv_misc/lv_txt.h" #include "../lv_misc/lv_math.h" #include "../lv_draw/lv_draw_label.h" @@ -56,12 +57,12 @@ lv_obj_t * lv_table_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor of table*/ lv_obj_t * new_table = lv_obj_create(par, copy); - lv_mem_assert(new_table); + LV_ASSERT_NO_MEM(new_table); if(new_table == NULL) return NULL; /*Allocate the table type specific extended data*/ lv_table_ext_t * ext = lv_obj_allocate_ext_attr(new_table, sizeof(lv_table_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_table); if(ancestor_scrl_design == NULL) ancestor_scrl_design = lv_obj_get_design_cb(new_table); diff --git a/src/lv_objx/lv_tabview.c b/src/lv_objx/lv_tabview.c index ab0ad28a8..e9f3b72a0 100644 --- a/src/lv_objx/lv_tabview.c +++ b/src/lv_objx/lv_tabview.c @@ -10,6 +10,7 @@ #if LV_USE_TABVIEW != 0 #include "lv_btnm.h" +#include "../lv_core/lv_debug.h" #include "../lv_themes/lv_theme.h" #include "../lv_misc/lv_anim.h" #include "../lv_core/lv_disp.h" @@ -71,13 +72,13 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor of tab*/ lv_obj_t * new_tabview = lv_obj_create(par, copy); - lv_mem_assert(new_tabview); + LV_ASSERT_NO_MEM(new_tabview); if(new_tabview == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_tabview); /*Allocate the tab type specific extended data*/ lv_tabview_ext_t * ext = lv_obj_allocate_ext_attr(new_tabview, sizeof(lv_tabview_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; /*Initialize the allocated 'ext' */ @@ -103,7 +104,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy) /*Init the new tab tab*/ if(copy == NULL) { ext->tab_name_ptr = lv_mem_alloc(sizeof(char *)); - lv_mem_assert(ext->tab_name_ptr); + LV_ASSERT_NO_MEM(ext->tab_name_ptr); if(ext->tab_name_ptr == NULL) return NULL; ext->tab_name_ptr[0] = ""; ext->tab_cnt = 0; @@ -161,7 +162,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy) #endif ext->tab_name_ptr = lv_mem_alloc(sizeof(char *)); - lv_mem_assert(ext->tab_name_ptr); + LV_ASSERT_NO_MEM(ext->tab_name_ptr); if(ext->tab_name_ptr == NULL) return NULL; ext->tab_name_ptr[0] = ""; lv_btnm_set_map(ext->btns, ext->tab_name_ptr); @@ -225,7 +226,7 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name) /*Extend the button matrix map with the new name*/ char * name_dm; name_dm = lv_mem_alloc(strlen(name) + 1); /*+1 for the the closing '\0' */ - lv_mem_assert(name_dm); + LV_ASSERT_NO_MEM(name_dm); if(name_dm == NULL) return NULL; strcpy(name_dm, name); @@ -242,7 +243,7 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name) break; } - lv_mem_assert(ext->tab_name_ptr); + LV_ASSERT_NO_MEM(ext->tab_name_ptr); if(ext->tab_name_ptr == NULL) return NULL; /* FIXME: It is not possible yet to switch tab button position from/to top/bottom from/to left/right at runtime. diff --git a/src/lv_objx/lv_tileview.c b/src/lv_objx/lv_tileview.c index ae86ea7dd..b1c1b74cd 100644 --- a/src/lv_objx/lv_tileview.c +++ b/src/lv_objx/lv_tileview.c @@ -11,6 +11,7 @@ #include #include "lv_cont.h" +#include "../lv_core/lv_debug.h" #include "../lv_themes/lv_theme.h" /********************* @@ -65,12 +66,12 @@ lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor of tileview*/ lv_obj_t * new_tileview = lv_page_create(par, copy); - lv_mem_assert(new_tileview); + LV_ASSERT_NO_MEM(new_tileview); if(new_tileview == NULL) return NULL; /*Allocate the tileview type specific extended data*/ lv_tileview_ext_t * ext = lv_obj_allocate_ext_attr(new_tileview, sizeof(lv_tileview_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_tileview); if(ancestor_scrl_signal == NULL) ancestor_scrl_signal = lv_obj_get_signal_cb(lv_page_get_scrl(new_tileview)); diff --git a/src/lv_objx/lv_win.c b/src/lv_objx/lv_win.c index 7311d5a37..2cab007d8 100644 --- a/src/lv_objx/lv_win.c +++ b/src/lv_objx/lv_win.c @@ -9,6 +9,7 @@ #include "lv_win.h" #if LV_USE_WIN != 0 +#include "../lv_core/lv_debug.h" #include "../lv_themes/lv_theme.h" #include "../lv_core/lv_disp.h" @@ -51,14 +52,14 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy) /*Create the ancestor object*/ lv_obj_t * new_win = lv_obj_create(par, copy); - lv_mem_assert(new_win); + LV_ASSERT_NO_MEM(new_win); if(new_win == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_win); /*Allocate the object type specific extended data*/ lv_win_ext_t * ext = lv_obj_allocate_ext_attr(new_win, sizeof(lv_win_ext_t)); - lv_mem_assert(ext); + LV_ASSERT_NO_MEM(ext); if(ext == NULL) return NULL; ext->page = NULL;