Fixed a bug in the image_display widget. If you switched it between

images of a different size while any kind of zoom was in effect
it could cause a segmentation fault.
This commit is contained in:
Davis King 2011-06-19 14:43:32 -04:00
parent b5511d2cb3
commit 29d6051e59

View File

@ -3228,9 +3228,16 @@ namespace dlib
// if the new image has a different size when compared to the previous image
// then we should readjust the total rectangle size.
if (new_img.nr() != img.nr() || new_img.nc() != img.nc())
set_total_rect_size(new_img.nc(), new_img.nr());
{
if (zoom_in_scale != 1)
set_total_rect_size(new_img.nc()*zoom_in_scale, new_img.nr()*zoom_in_scale);
else
set_total_rect_size(new_img.nc()/zoom_out_scale, new_img.nr()/zoom_out_scale);
}
else
{
parent.invalidate_rectangle(rect);
}
assign_image_scaled(img,new_img);
}