Only release old img_src if a new img_src is about to be set

This commit is contained in:
fvanroie 2022-10-25 23:39:47 +02:00
parent ac7e0d6c8d
commit 7aa7fbbbe8

View File

@ -1302,22 +1302,24 @@ static hasp_attribute_type_t special_attribute_src(lv_obj_t* obj, const char* pa
if(!obj_check_type(obj, LV_HASP_IMAGE)) return HASP_ATTR_TYPE_NOT_FOUND; if(!obj_check_type(obj, LV_HASP_IMAGE)) return HASP_ATTR_TYPE_NOT_FOUND;
if(update) { if(update) {
my_image_release_resources(obj);
if(payload != strstr_P(payload, PSTR("http://")) && // not start with http if(payload != strstr_P(payload, PSTR("http://")) && // not start with http
payload != strstr_P(payload, PSTR("https://"))) { // not start with https payload != strstr_P(payload, PSTR("https://"))) { // not start with https
if(payload == strstr_P(payload, PSTR("L:"))) { // startsWith command/ if(payload == strstr_P(payload, PSTR("L:"))) { // startsWith command/
my_image_release_resources(obj);
lv_img_set_src(obj, payload); lv_img_set_src(obj, payload);
} else if(payload == strstr_P(payload, PSTR("/littlefs/"))) { // startsWith command/ } else if(payload == strstr_P(payload, PSTR("/littlefs/"))) { // startsWith command/
char tempsrc[64] = "L:"; char tempsrc[64] = "L:";
strncpy(tempsrc + 2, payload + 10, sizeof(tempsrc) - 2); strncpy(tempsrc + 2, payload + 10, sizeof(tempsrc) - 2);
my_image_release_resources(obj);
lv_img_set_src(obj, tempsrc); lv_img_set_src(obj, tempsrc);
} else { } else {
char tempsrc[64] = LV_SYMBOL_DUMMY; char tempsrc[64] = LV_SYMBOL_DUMMY;
strncpy(tempsrc + 3, payload, sizeof(tempsrc) - 3); strncpy(tempsrc + 3, payload, sizeof(tempsrc) - 3);
my_image_release_resources(obj);
lv_img_set_src(obj, tempsrc); lv_img_set_src(obj, tempsrc);
} }
@ -1458,6 +1460,7 @@ static hasp_attribute_type_t special_attribute_src(lv_obj_t* obj, const char* pa
img_dsc->header.h, img_dsc->header.cf, img_dsc->data_size); img_dsc->header.h, img_dsc->header.cf, img_dsc->data_size);
} }
my_image_release_resources(obj);
lv_img_set_src(obj, img_dsc); lv_img_set_src(obj, img_dsc);
// LOG_DEBUG(TAG_ATTR, "%s %d %x -> %x", __FILE__, __LINE__, img_buf_start, img_buf_start_pos); // LOG_DEBUG(TAG_ATTR, "%s %d %x -> %x", __FILE__, __LINE__, img_buf_start, img_buf_start_pos);