From 7eae50a52d63b7f0434fdb75fc09b0901a0140cc Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 29 Apr 2014 09:06:08 +0200 Subject: Fix assert on justification of QTextLine with only spaces In the justification code, we unconditionally subtracted one from the line_length, but then compared the result to 0 afterwards, so we did not support when the line_length is 0 initially, which can happen if it only consists of spaces (in which case trailingSpaces will be non-zero and line_length will be zero.) The fix is to bail out for both strings of length 1 and length 0. [ChangeLog][Text] Fixed an assert when justifying a QTextLine which only contains spaces. Task-number: QTBUG-38520 Change-Id: Ib04993f47eb2f9f7fc49c4a5400f18f9682a72f2 Reviewed-by: Simon Hausmann Reviewed-by: Konstantin Ritt Reviewed-by: Lars Knoll --- src/gui/text/qtextengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 34788dc4dc..67dedca760 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2057,7 +2057,7 @@ void QTextEngine::justify(const QScriptLine &line) // subtract one char more, as we can't justfy after the last character --line_length; - if (!line_length) + if (line_length <= 0) return; int firstItem = findItem(line.from); -- cgit v1.2.3