diff --git a/src/corelib/io/qdebug_p.h b/src/corelib/io/qdebug_p.h index 9b048ae9ab9..732929e7215 100644 --- a/src/corelib/io/qdebug_p.h +++ b/src/corelib/io/qdebug_p.h @@ -52,6 +52,10 @@ static inline void formatQRect(QDebug &debug, const Rect &rect) const qint64 w = qint64(rect.right()) - rect.left() + 1; const qint64 h = qint64(rect.bottom()) - rect.top() + 1; debug << w << 'x' << h; + + constexpr qint64 M = (std::numeric_limits::max)(); + if (w > M || h > M) + debug << " (oversized)"; } else { debug << rect.width() << 'x' << rect.height(); } diff --git a/tests/auto/corelib/tools/qrect/tst_qrect.cpp b/tests/auto/corelib/tools/qrect/tst_qrect.cpp index ebf1d1b38bd..d7312ffc322 100644 --- a/tests/auto/corelib/tools/qrect/tst_qrect.cpp +++ b/tests/auto/corelib/tools/qrect/tst_qrect.cpp @@ -4526,7 +4526,7 @@ void tst_QRect::debug() str.clear(); debug << QRect(QPoint(INT_MIN, INT_MIN), QPoint(INT_MAX, INT_MAX)); - QCOMPARE(str, "QRect(-2147483648,-2147483648 4294967296x4294967296)"); + QCOMPARE(str, "QRect(-2147483648,-2147483648 4294967296x4294967296 (oversized))"); } QTEST_MAIN(tst_QRect)