[Kst] branches/work/kst/portto4/kst/src/libkstapp
Peter Kümmel
syntheticpp at gmx.net
Thu May 27 17:31:55 CEST 2010
SVN commit 1131188 by kuemmel:
prevent endless loop (could happen with NAN numbers)
M +6 -4 plotaxis.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/plotaxis.cpp #1131187:1131188
@@ -909,7 +909,6 @@
qreal drdu = 1.0; // interpreted units per raw units;
qreal rOffset = 0.0; // r = drdu*u + rOffset;
qreal uMajorTickSpacing; // major Tick spacing in iterpreted units
- qreal nextTick;
if (_orientation == Qt::Horizontal) {
min = plotItem()->projectionRect().left();
@@ -940,15 +939,18 @@
qreal majorTickSpacing = uMajorTickSpacing * drdu;
int i = 0;
- qreal uNextTick = uFirstTick;
+ qreal lastTick = 12345678;
while (1) {
- uNextTick = uFirstTick + i++ * uMajorTickSpacing;
+ qreal uNextTick = uFirstTick + i++ * uMajorTickSpacing;
if (fabs(uNextTick)<uMajorTickSpacing*0.5) { // fix roundoff...
uNextTick = 0.0;
}
if (uNextTick > uMax)
break;
- nextTick = uNextTick * drdu + rOffset;
+ qreal nextTick = uNextTick * drdu + rOffset;
+ if (lastTick == uNextTick) // prevent endless loop
+ break;
+ lastTick = nextTick;
ticks << nextTick;
// FULL_PRECISION - 2 because round off errors mean you never actually quite get
// full precision...
More information about the Kst
mailing list