Prevent zoom to fit from going to crazy zooms on blank canvas

Fix #6062
This commit is contained in:
Marek Roszko 2020-10-19 18:51:32 -04:00
parent c9d14700a7
commit f1e2bdc2d0
1 changed files with 8 additions and 0 deletions

View File

@ -315,6 +315,14 @@ int COMMON_TOOLS::doZoomFit( ZOOM_FIT_TYPE_T aFitType )
double scale = view->GetScale() / std::max( fabs( vsize.x / screenSize.x ),
fabs( vsize.y / screenSize.y ) );
// if the scale isn't finite (most likely due to an empty canvas)
// simply just make sure we are centered and quit out of trying to zoom to fit
if( !std::isfinite( scale ) )
{
view->SetCenter( VECTOR2D( 0, 0 ) );
return 0;
}
// Reserve a 2% margin around bounding boxes.
double margin_scale_factor = 1.02;