From cf5519e983123b787990b688f7c702744c8837c7 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.2 Change-Id: I7187bd81d3cbcc11ba898e015bd2a8ec64e3bf34 Reviewed-by: MÃ¥rten Nordheim (cherry picked from commit 33d606412d8c2dc9ad3c0129af5bc8a74ce650be) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit f4cd637c8a13310e5952c30677ce144ec3d22633) --- 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 a6675422cd3..1c61416376e 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) { QString tag; for (int 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++; @@ -3437,7 +3437,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;