summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtextlayout
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2009-10-29 17:14:47 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2009-10-29 17:20:45 +0100
commit2f9c37c4b48c4b5005c89f1c5a5fa036e1e22811 (patch)
tree5f5d20b7d8fb6f77c0469ee5542a9adb5ecd0479 /tests/auto/qtextlayout
parent4531ffbd8aa2cc0ae656715e449caca1649c18b9 (diff)
Avoid infinite loop when laying out text with unconvertible chars
When the stringToCMap() fails, it can be because it did not have enough space in the layout, or it can because of other errors. In order to implement "try-again" processing in a simple way, we had an infinite loop which assumed that stringToCMap() would always succeed in the second run (which would be the case if the only possible error was "not enough space".) Since there are other possible failures not related to the number of glyphs, you could easily get into an infinite loop here, e.g. when laying out text that contains the Byte Order Mark. The fix changes the implementation to explictly try stringToCMap() twice at max, and is also how it's implemented in the default qtextengine.cpp. Task-number: QTBUG-4680 Reviewed-by: Trond
Diffstat (limited to 'tests/auto/qtextlayout')
-rw-r--r--tests/auto/qtextlayout/tst_qtextlayout.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp
index fe87dfb175..7c3f4f2481 100644
--- a/tests/auto/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp
@@ -118,6 +118,7 @@ private slots:
void smallTextLengthWordWrap();
void smallTextLengthWrapAtWordBoundaryOrAnywhere();
void testLineBreakingAllSpaces();
+ void lineWidthFromBOM();
private:
@@ -1306,6 +1307,18 @@ void tst_QTextLayout::columnWrapWithTabs()
}
+void tst_QTextLayout::lineWidthFromBOM()
+{
+ const QString string(QChar(0xfeff)); // BYTE ORDER MARK
+ QTextLayout layout(string);
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ line.setLineWidth(INT_MAX / 256);
+ layout.endLayout();
+
+ // Don't spin into an infinite loop
+ }
+
QTEST_MAIN(tst_QTextLayout)
#include "tst_qtextlayout.moc"