cc_item_picture.cpp: avoid possible crash if image paint was failed

This commit is contained in:
2019-03-26 10:00:09 +01:00
parent edc597748d
commit 17b57d0914

View File

@@ -322,15 +322,20 @@ void CComponentsPicture::paintPicture()
is_image_painted = g_PicViewer->DisplayImage(pic_name, x_pic, y_pic, width-2*fr_thickness, height-2*fr_thickness); is_image_painted = g_PicViewer->DisplayImage(pic_name, x_pic, y_pic, width-2*fr_thickness, height-2*fr_thickness);
else else
is_image_painted = frameBuffer->paintIcon(pic_name, x_pic, y_pic, height, 1, do_paint, paint_bg, col_body); is_image_painted = frameBuffer->paintIcon(pic_name, x_pic, y_pic, height, 1, do_paint, paint_bg, col_body);
frameBuffer->SetTransparentDefault();
if (enable_cache && do_scale){ if (is_image_painted){
dprintf(DEBUG_DEBUG, "\033[31m[CComponentsPicture] %s - %d: create cached image from pic_name=%s\033[0m\n", __func__, __LINE__, pic_name.c_str()); frameBuffer->SetTransparentDefault();
dxc = width-2*fr_thickness; if (enable_cache && do_scale){
dyc = height-2*fr_thickness; dprintf(DEBUG_DEBUG, "\033[32m[CComponentsPicture] %s - %d: create cached image from pic_name=%s\033[0m\n", __func__, __LINE__, pic_name.c_str());
image_cache = getScreen(x_pic, y_pic, dxc, dyc); dxc = width-2*fr_thickness;
dyc = height-2*fr_thickness;
image_cache = getScreen(x_pic, y_pic, dxc, dyc);
}
} }
else
dprintf(DEBUG_NORMAL, "\033[31m[CComponentsPicture] %s - %d: error: paint of image failed: %s\033[0m\n", __func__, __LINE__, pic_name.c_str());
}else{ }else{
dprintf(DEBUG_DEBUG, "\033[36m[CComponentsPicture] %s - %d: paint cached image from pic_name=%s\033[0m\n", __func__, __LINE__, pic_name.c_str()); dprintf(DEBUG_DEBUG, "\033[32m[CComponentsPicture] %s - %d: paint cached image from pic_name=%s\033[0m\n", __func__, __LINE__, pic_name.c_str());
frameBuffer->RestoreScreen(x_pic, y_pic, dxc, dyc, image_cache); frameBuffer->RestoreScreen(x_pic, y_pic, dxc, dyc, image_cache);
} }
} }