--- src/gui/painting/qfixed_p.h +++ src/gui/painting/qfixed_p.h @@ -18,6 +18,7 @@ #include #include "QtCore/qdebug.h" #include "QtCore/qpoint.h" +#include "QtCore/qnumeric.h" #include "QtCore/qsize.h" QT_BEGIN_NAMESPACE @@ -136,6 +137,22 @@ constexpr inline QFixed operator+(uint i, QFixed d) { return d+i; } constexpr inline QFixed operator-(uint i, QFixed d) { return -(d-i); } // constexpr inline QFixed operator*(qreal d, QFixed d2) { return d2*d; } +inline bool qAddOverflow(QFixed v1, QFixed v2, QFixed *r) +{ + int val; + bool result = qAddOverflow(v1.value(), v2.value(), &val); + r->setValue(val); + return result; +} + +inline bool qMulOverflow(QFixed v1, QFixed v2, QFixed *r) +{ + int val; + bool result = qMulOverflow(v1.value(), v2.value(), &val); + r->setValue(val); + return result; +} + #ifndef QT_NO_DEBUG_STREAM inline QDebug &operator<<(QDebug &dbg, QFixed f) { return dbg << f.toReal(); } --- src/gui/text/qtextlayout.cpp +++ src/gui/text/qtextlayout.cpp @@ -2105,11 +2105,14 @@ found: eng->maxWidth = qMax(eng->maxWidth, line.textWidth); } else { eng->minWidth = qMax(eng->minWidth, lbh.minw); - eng->maxWidth += line.textWidth; + if (qAddOverflow(eng->maxWidth, line.textWidth, &eng->maxWidth)) + eng->maxWidth = QFIXED_MAX; } - if (line.textWidth > 0 && item < eng->layoutData->items.size()) - eng->maxWidth += lbh.spaceData.textWidth; + if (line.textWidth > 0 && item < eng->layoutData->items.size()) { + if (qAddOverflow(eng->maxWidth, lbh.spaceData.textWidth, &eng->maxWidth)) + eng->maxWidth = QFIXED_MAX; + } line.textWidth += trailingSpace; if (lbh.spaceData.length) {