mathplot: fix freeze in scale ticks calculation

This commit is contained in:
Tomasz Wlostowski 2016-08-11 14:42:02 +02:00 committed by Maciej Suminski
parent 36297f84c3
commit f4033f776f
1 changed files with 10 additions and 2 deletions

View File

@ -1005,7 +1005,10 @@ void mpScaleY::recalculateTicks ( wxDC & dc, mpWindow & w )
double zeroOffset = 100000000.0; double zeroOffset = 100000000.0;
//printf("maxVVis %.3f\n", maxVvis); //printf("maxVVis %.3f\n", maxVvis);
while ( v < maxVvis ) const int iterLimit = 1000;
int i = 0;
while ( v < maxVvis && i < iterLimit)
{ {
m_tickValues.push_back(v); m_tickValues.push_back(v);
@ -1016,6 +1019,12 @@ void mpScaleY::recalculateTicks ( wxDC & dc, mpWindow & w )
v+=bestStep; v+=bestStep;
} }
// something weird happened...
if ( i == iterLimit )
{
m_tickValues.clear();
}
if ( zeroOffset <= bestStep ) if ( zeroOffset <= bestStep )
{ {
for( double& t: m_tickValues ) for( double& t: m_tickValues )
@ -3625,4 +3634,3 @@ double mpFXY::y2s(double y) const
{ {
return m_scaleY->TransformToPlot( y ); return m_scaleY->TransformToPlot( y );
} }