From 33d606412d8c2dc9ad3c0129af5bc8a74ce650be Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Wed, 4 Oct 2023 14:40:40 +0300 Subject: [PATCH] qtextdocument: use qsizetype more MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit in Qt::mightBeRichText, Qt::convertFromPlainText and emitFrameStyle to support large strings Pick-to: 6.6 6.5 6.2 Change-Id: I7187bd81d3cbcc11ba898e015bd2a8ec64e3bf34 Reviewed-by: MÃ¥rten Nordheim --- src/gui/text/qtextdocument.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index dc24db1efb..ea259873e2 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -65,7 +65,7 @@ bool Qt::mightBeRichText(const QString& text) { if (text.isEmpty()) return false; - int start = 0; + qsizetype start = 0; while (start < text.size() && text.at(start).isSpace()) ++start; @@ -88,7 +88,7 @@ bool Qt::mightBeRichText(const QString& text) if (QStringView{text}.mid(start, 5).compare("', open); + const qsizetype close = text.indexOf(u'>', open); if (close > -1) { QVarLengthArray tag; for (qsizetype i = open + 1; i < close; ++i) { @@ -131,12 +131,12 @@ bool Qt::mightBeRichText(const QString& text) */ QString Qt::convertFromPlainText(const QString &plain, Qt::WhiteSpaceMode mode) { - int col = 0; + qsizetype col = 0; QString rich; rich += "

"_L1; - for (int i = 0; i < plain.size(); ++i) { + for (qsizetype i = 0; i < plain.size(); ++i) { if (plain[i] == u'\n'){ - int c = 1; + qsizetype c = 1; while (i+1 < plain.size() && plain[i+1] == u'\n') { i++; c++; @@ -3453,7 +3453,7 @@ void QTextHtmlExporter::emitFrameStyle(const QTextFrameFormat &format, FrameType { const auto styleAttribute = " style=\""_L1; html += styleAttribute; - const int originalHtmlLength = html.size(); + const qsizetype originalHtmlLength = html.size(); if (frameType == TextFrame) html += "-qt-table-type: frame;"_L1;