summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEduardo M. Fleury <eduardo.fleury@openbossa.org>2009-10-27 20:29:02 (GMT)
committerEduardo M. Fleury <eduardo.fleury@openbossa.org>2009-11-04 23:28:27 (GMT)
commit6c758ba18ded5ed1ac518777cb59e519142d292c (patch)
treebed5b0066df47f96682f1e705dded0a636faa06c /src
parentd4d6901d82476e92f4c318d8d6e9da5d3410920f (diff)
downloadQt-6c758ba18ded5ed1ac518777cb59e519142d292c.zip
Qt-6c758ba18ded5ed1ac518777cb59e519142d292c.tar.gz
Qt-6c758ba18ded5ed1ac518777cb59e519142d292c.tar.bz2
QGAL: Avoid false assertions due to floating point precision errors
Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
Diffstat (limited to 'src')
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.cpp22
-rw-r--r--src/gui/graphicsview/qsimplex_p.cpp2
-rw-r--r--src/gui/graphicsview/qsimplex_p.h2
3 files changed, 14 insertions, 12 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
index ad7d657..baff206 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -341,16 +341,16 @@ void SequentialAnchorData::updateChildrenSizes()
// ### REMOVE ME
// ### check whether we are guarantee to get those or we need to warn stuff at this
// point.
- Q_ASSERT(sizeAtMinimum > minSize || qFuzzyCompare(sizeAtMinimum, minSize));
- Q_ASSERT(sizeAtPreferred > minSize || qFuzzyCompare(sizeAtPreferred, minSize));
- Q_ASSERT(sizeAtExpanding > minSize || qFuzzyCompare(sizeAtExpanding, minSize));
- Q_ASSERT(sizeAtMaximum > minSize || qFuzzyCompare(sizeAtMaximum, minSize));
+ Q_ASSERT(sizeAtMinimum > minSize || qAbs(sizeAtMinimum - minSize) < 0.00000001);
+ Q_ASSERT(sizeAtPreferred > minSize || qAbs(sizeAtPreferred - minSize) < 0.00000001);
+ Q_ASSERT(sizeAtExpanding > minSize || qAbs(sizeAtExpanding - minSize) < 0.00000001);
+ Q_ASSERT(sizeAtMaximum > minSize || qAbs(sizeAtMaximum - minSize) < 0.00000001);
// These may be false if this anchor was in parallel with the layout stucture
- // Q_ASSERT(sizeAtMinimum < maxSize || qFuzzyCompare(sizeAtMinimum, maxSize));
- // Q_ASSERT(sizeAtPreferred < maxSize || qFuzzyCompare(sizeAtPreferred, maxSize));
- // Q_ASSERT(sizeAtExpanding < maxSize || qFuzzyCompare(sizeAtExpanding, maxSize));
- // Q_ASSERT(sizeAtMaximum < maxSize || qFuzzyCompare(sizeAtMaximum, maxSize));
+ // Q_ASSERT(sizeAtMinimum < maxSize || qAbs(sizeAtMinimum - maxSize) < 0.00000001);
+ // Q_ASSERT(sizeAtPreferred < maxSize || qAbs(sizeAtPreferred - maxSize) < 0.00000001);
+ // Q_ASSERT(sizeAtExpanding < maxSize || qAbs(sizeAtExpanding - maxSize) < 0.00000001);
+ // Q_ASSERT(sizeAtMaximum < maxSize || qAbs(sizeAtMaximum - maxSize) < 0.00000001);
// Band here refers if the value is in the Minimum To Preferred
// band (the lower band) or the Preferred To Maximum (the upper band).
@@ -2536,8 +2536,9 @@ bool QGraphicsAnchorLayoutPrivate::solveMinMax(const QList<QSimplexConstraint *>
QList<AnchorData *> variables = getVariables(constraints);
for (int i = 0; i < variables.size(); ++i) {
AnchorData *ad = static_cast<AnchorData *>(variables[i]);
- Q_ASSERT(ad->result >= ad->minSize || qFuzzyCompare(ad->result, ad->minSize));
ad->sizeAtMinimum = ad->result;
+ Q_ASSERT(ad->sizeAtMinimum >= ad->minSize ||
+ qAbs(ad->sizeAtMinimum - ad->minSize) < 0.00000001);
}
// Calculate maximum values
@@ -2546,8 +2547,9 @@ bool QGraphicsAnchorLayoutPrivate::solveMinMax(const QList<QSimplexConstraint *>
// Save sizeAtMaximum results
for (int i = 0; i < variables.size(); ++i) {
AnchorData *ad = static_cast<AnchorData *>(variables[i]);
- // Q_ASSERT(ad->result <= ad->maxSize || qFuzzyCompare(ad->result, ad->maxSize));
ad->sizeAtMaximum = ad->result;
+ // Q_ASSERT(ad->sizeAtMaximum <= ad->maxSize ||
+ // qAbs(ad->sizeAtMaximum - ad->maxSize) < 0.00000001);
}
}
return feasible;
diff --git a/src/gui/graphicsview/qsimplex_p.cpp b/src/gui/graphicsview/qsimplex_p.cpp
index 86b10b4..cd40f9e 100644
--- a/src/gui/graphicsview/qsimplex_p.cpp
+++ b/src/gui/graphicsview/qsimplex_p.cpp
@@ -288,7 +288,7 @@ bool QSimplex::setConstraints(const QList<QSimplexConstraint *> newConstraints)
// original problem.
// Otherwise, we clean up our structures and report there is
// no feasible solution.
- if (valueAt(0, columns - 1) != 0.0) {
+ if ((valueAt(0, columns - 1) != 0.0) && (qAbs(valueAt(0, columns - 1)) > 0.00001)) {
qWarning() << "QSimplex: No feasible solution!";
clearDataStructures();
return false;
diff --git a/src/gui/graphicsview/qsimplex_p.h b/src/gui/graphicsview/qsimplex_p.h
index 084ad7f..a5816d1 100644
--- a/src/gui/graphicsview/qsimplex_p.h
+++ b/src/gui/graphicsview/qsimplex_p.h
@@ -107,7 +107,7 @@ struct QSimplexConstraint
Q_ASSERT(constant > 0 || qFuzzyCompare(1, 1 + constant));
- if ((leftHandSide == constant) || qFuzzyCompare(1000 + leftHandSide, 1000 + constant))
+ if ((leftHandSide == constant) || qAbs(leftHandSide - constant) < 0.00000001)
return true;
switch (ratio) {