Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 93e737e7 authored by Ivan Yossi's avatar Ivan Yossi 👌

Fix hang when utf line break is used

Break the loop: if adding an offset to the number of columns doesn't
increase the line length, we break out of the loop to avoid an
infinite loop on loading some files.

Shift + Enter creates an utf break character which breaks
the lenght calculation. Also added a reptition flag to avoid
any other hang if there is a strange symbol.

BUG:410402

ref:https://invent.kde.org/kde/krita/merge_requests/128


(cherry picked from commit 535ca1fc)
parent 34eb31dc
......@@ -661,7 +661,7 @@ bool KoSvgTextChunkShape::loadSvg(const KoXmlElement &e, SvgLoadingContext &cont
namespace {
QString cleanUpString(QString text) {
text.replace(QRegExp("[\\r\\n]"), "");
text.replace(QRegExp("[\\r\\n\u2028]"), "");
text.replace(QRegExp(" {2,}"), " ");
return text;
}
......
......@@ -329,6 +329,8 @@ struct LayoutChunkWrapper
KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(startPos == m_addedChars, currentTextPos);
KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(lastPos < m_layout->text().size(), currentTextPos);
// qDebug() << m_layout->text();
QTextLine line;
std::swap(line, m_danglingLine);
......@@ -350,8 +352,17 @@ struct LayoutChunkWrapper
// grow to avoid missing glyphs
int charOffset = 0;
int noChangeCount = 0;
while (line.textLength() < numChars) {
int tl = line.textLength();
line.setNumColumns(numChars + charOffset);
if (tl == line.textLength()) {
noChangeCount++;
// 5 columns max are needed to discover tab char. Set to 10 to be safe.
if (noChangeCount > 10) break;
} else {
noChangeCount = 0;
}
charOffset++;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment