Fix specific overflow in qtextlayout
Adds qAddOverflow and qMulOverflow definitions to QFixed Fixes: QTBUG-113337 Change-Id: I13579306defceaccdc0fbb1ec0e9b77c6f8d1af9 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 7b7a01c266b507636eab51a36328c7c72d82d93c) Reviewed-by: Michael Brüning <michael.bruning@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
be0a975a85
commit
3ef2308347
@ -51,11 +51,19 @@
|
|||||||
// We mean it.
|
// We mean it.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
|
||||||
#include <QtGui/private/qtguiglobal_p.h>
|
#include <QtGui/private/qtguiglobal_p.h>
|
||||||
#include "QtCore/qdebug.h"
|
#include "QtCore/qdebug.h"
|
||||||
#include "QtCore/qpoint.h"
|
#include "QtCore/qpoint.h"
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
#include <qt_windows.h> // to suppress min, max macros.
|
||||||
|
#endif
|
||||||
|
#include <QtCore/private/qnumeric_p.h>
|
||||||
#include "QtCore/qsize.h"
|
#include "QtCore/qsize.h"
|
||||||
|
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
struct QFixed {
|
struct QFixed {
|
||||||
@ -182,6 +190,14 @@ Q_DECL_CONSTEXPR inline bool operator<(int i, const QFixed &f) { return i * 64 <
|
|||||||
Q_DECL_CONSTEXPR inline bool operator>(const QFixed &f, int i) { return f.value() > i * 64; }
|
Q_DECL_CONSTEXPR inline bool operator>(const QFixed &f, int i) { return f.value() > i * 64; }
|
||||||
Q_DECL_CONSTEXPR inline bool operator>(int i, const QFixed &f) { return i * 64 > f.value(); }
|
Q_DECL_CONSTEXPR inline bool operator>(int i, const QFixed &f) { return i * 64 > f.value(); }
|
||||||
|
|
||||||
|
inline bool qAddOverflow(QFixed v1, QFixed v2, QFixed *r)
|
||||||
|
{
|
||||||
|
int val;
|
||||||
|
bool result = add_overflow(v1.value(), v2.value(), &val);
|
||||||
|
r->setValue(val);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG_STREAM
|
#ifndef QT_NO_DEBUG_STREAM
|
||||||
inline QDebug &operator<<(QDebug &dbg, const QFixed &f)
|
inline QDebug &operator<<(QDebug &dbg, const QFixed &f)
|
||||||
{ return dbg << f.toReal(); }
|
{ return dbg << f.toReal(); }
|
||||||
|
@ -2163,11 +2163,14 @@ found:
|
|||||||
eng->maxWidth = qMax(eng->maxWidth, line.textWidth);
|
eng->maxWidth = qMax(eng->maxWidth, line.textWidth);
|
||||||
} else {
|
} else {
|
||||||
eng->minWidth = qMax(eng->minWidth, lbh.minw);
|
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())
|
if (line.textWidth > 0 && item < eng->layoutData->items.size()) {
|
||||||
eng->maxWidth += lbh.spaceData.textWidth;
|
if (qAddOverflow(eng->maxWidth, lbh.spaceData.textWidth, &eng->maxWidth))
|
||||||
|
eng->maxWidth = QFIXED_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
line.textWidth += trailingSpace;
|
line.textWidth += trailingSpace;
|
||||||
if (lbh.spaceData.length) {
|
if (lbh.spaceData.length) {
|
||||||
|
@ -17,7 +17,7 @@ QMAKE_USE_PRIVATE += \
|
|||||||
user32 \
|
user32 \
|
||||||
winmm
|
winmm
|
||||||
|
|
||||||
DEFINES *= QT_NO_CAST_FROM_ASCII QT_NO_FOREACH
|
DEFINES *= QT_NO_CAST_FROM_ASCII QT_NO_FOREACH NOMINMAX
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/qwindowswindow.cpp \
|
$$PWD/qwindowswindow.cpp \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user