summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authormakuukka <qt-info@nokia.com>2009-05-29 07:08:27 (GMT)
committerJason Barron <jbarron@trolltech.com>2009-06-10 06:38:13 (GMT)
commitb97671a3b40623c1499c13c3d74c896ac6b9406f (patch)
tree8f68eb88a7449799ad245f484b6c358935c85805 /src/corelib
parentdcaa6ab545e7532b5455734bd8d234cb76b152fa (diff)
downloadQt-b97671a3b40623c1499c13c3d74c896ac6b9406f.zip
Qt-b97671a3b40623c1499c13c3d74c896ac6b9406f.tar.gz
Qt-b97671a3b40623c1499c13c3d74c896ac6b9406f.tar.bz2
Force qRound64() to take a double on platforms where qreal is a float.
In Symbian qreal is defined as float. And in qround64 the parameter was qreal. This qround64 is used (only) in qvariant::convert, when converting from double to e.g. int. This caused overflow bug for some (close to max int) values, because in convert chain double value was casted to float. Task-number: 250267 Reviewed-By: Samuel Rødal Reviewed-By: Jason Barron
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qglobal.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 27aaac1..b075db6 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1055,8 +1055,13 @@ inline T qAbs(const T &t) { return t >= 0 ? t : -t; }
inline int qRound(qreal d)
{ return d >= 0.0 ? int(d + 0.5) : int(d - int(d-1) + 0.5) + int(d-1); }
+#if defined(QT_NO_FPU) || defined(QT_ARCH_ARM) || defined(QT_ARCH_WINDOWSCE) || defined(QT_ARCH_SYMBIAN)
+inline qint64 qRound64(double d)
+{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - qint64(d-1) + 0.5) + qint64(d-1); }
+#else
inline qint64 qRound64(qreal d)
{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - qint64(d-1) + 0.5) + qint64(d-1); }
+#endif
template <typename T>
inline const T &qMin(const T &a, const T &b) { if (a < b) return a; return b; }