fix(obj): fix arduino compile warnings (#4807)
Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
This commit is contained in:
@@ -149,9 +149,9 @@ void lv_init(void)
|
||||
lv_img_cache_set_size(LV_IMG_CACHE_DEF_SIZE);
|
||||
#endif
|
||||
/*Test if the IDE has UTF-8 encoding*/
|
||||
char * txt = "Á";
|
||||
const char * txt = "Á";
|
||||
|
||||
uint8_t * txt_u8 = (uint8_t *)txt;
|
||||
const uint8_t * txt_u8 = (uint8_t *)txt;
|
||||
if(txt_u8[0] != 0xc3 || txt_u8[1] != 0x81 || txt_u8[2] != 0x00) {
|
||||
LV_LOG_WARN("The strings have no UTF-8 encoding. Non-ASCII characters won't be displayed.");
|
||||
}
|
||||
|
||||
@@ -74,14 +74,16 @@ void lv_checkbox_set_text(lv_obj_t * obj, const char * txt)
|
||||
size_t len = strlen(txt);
|
||||
#endif
|
||||
|
||||
if(!cb->static_txt) cb->txt = lv_mem_realloc(cb->txt, len + 1);
|
||||
else cb->txt = lv_mem_alloc(len + 1);
|
||||
char * _txt = (char *)cb->txt;
|
||||
if(!cb->static_txt) _txt = lv_mem_realloc(_txt, len + 1);
|
||||
else _txt = lv_mem_alloc(len + 1);
|
||||
#if LV_USE_ARABIC_PERSIAN_CHARS
|
||||
_lv_txt_ap_proc(txt, cb->txt);
|
||||
_lv_txt_ap_proc(txt, _txt);
|
||||
#else
|
||||
strcpy(cb->txt, txt);
|
||||
strcpy(_txt, txt);
|
||||
#endif
|
||||
|
||||
cb->txt = _txt;
|
||||
cb->static_txt = 0;
|
||||
|
||||
lv_obj_refresh_self_size(obj);
|
||||
@@ -92,7 +94,7 @@ void lv_checkbox_set_text_static(lv_obj_t * obj, const char * txt)
|
||||
{
|
||||
lv_checkbox_t * cb = (lv_checkbox_t *)obj;
|
||||
|
||||
if(!cb->static_txt) lv_mem_free(cb->txt);
|
||||
if(!cb->static_txt) lv_mem_free((void *)cb->txt);
|
||||
|
||||
cb->txt = (char *)txt;
|
||||
cb->static_txt = 1;
|
||||
@@ -138,7 +140,7 @@ static void lv_checkbox_destructor(const lv_obj_class_t * class_p, lv_obj_t * ob
|
||||
|
||||
lv_checkbox_t * cb = (lv_checkbox_t *)obj;
|
||||
if(!cb->static_txt) {
|
||||
lv_mem_free(cb->txt);
|
||||
lv_mem_free((void *)cb->txt);
|
||||
cb->txt = NULL;
|
||||
}
|
||||
LV_TRACE_OBJ_CREATE("finished");
|
||||
|
||||
@@ -28,7 +28,7 @@ extern "C" {
|
||||
|
||||
typedef struct {
|
||||
lv_obj_t obj;
|
||||
char * txt;
|
||||
const char * txt;
|
||||
uint32_t static_txt : 1;
|
||||
} lv_checkbox_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user