avoid division by zero and fix segfault

This commit is contained in:
Jacek Jendrzej
2016-05-23 14:17:25 +02:00
parent 5b6421b8b0
commit 9f20b27890
2 changed files with 3 additions and 3 deletions

View File

@@ -216,7 +216,7 @@ void CComponentsPicture::initCCItem()
* by setters setWidth/setHeight
* these steps are required to assign the current image dimensions to item dimensions
*/
if (keep_dx_aspect){
if (keep_dx_aspect && dy){
float h_ratio = float(height)*100/(float)dy;
width = int(h_ratio*(float)dx/100);
#ifdef BOXMODEL_APOLLO
@@ -224,7 +224,7 @@ void CComponentsPicture::initCCItem()
width = GetWidth4FB_HW_ACC(x+fr_thickness, width-2*fr_thickness)+2*fr_thickness;
#endif
}
if (keep_dy_aspect){
if (keep_dy_aspect & dx){
float w_ratio = float(width)*100/(float)dx;
height = int(w_ratio*(float)dy/100);
}