diff options
author | Liang Qi <liang.qi@qt.io> | 2016-10-06 13:04:47 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-10-06 20:12:27 +0200 |
commit | ef25620ac1acbe7a723b6b213d7d50468a748119 (patch) | |
tree | abdff2aed36655dfb0305d232b0ac48f8ad67391 /tests/auto/gui | |
parent | 669add92d9adc15ecfa0b2d62dd90ea9066d401e (diff) | |
parent | 6feec9da93032d11a768802ac2187d9d4153b1ec (diff) |
Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts:
mkspecs/features/mac/default_pre.prf
mkspecs/features/qpa/genericunixfontdatabase.prf
mkspecs/features/uikit/default_post.prf
mkspecs/features/uikit/resolve_config.prf
mkspecs/macx-ios-clang/features/default_post.prf
mkspecs/macx-ios-clang/features/resolve_config.prf
src/corelib/io/qiodevice.cpp
Change-Id: I6f210f71f177a3c3278a4f380542195e14e4b491
Diffstat (limited to 'tests/auto/gui')
-rw-r--r-- | tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp index 4d5af44ff1..0d1d0f1ae1 100644 --- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp @@ -135,6 +135,7 @@ private slots: void cursorInNonStopChars(); void nbsp(); void noModificationOfInputString(); + void superscriptCrash_qtbug53911(); private: QFont testFont; @@ -2197,5 +2198,61 @@ void tst_QTextLayout::noModificationOfInputString() } } +void tst_QTextLayout::superscriptCrash_qtbug53911() +{ + static int fontSizes = 64; + static QString layoutText = "THIS IS SOME EXAMPLE TEXT THIS IS SOME EXAMPLE TEXT"; + + QList<QTextLayout*> textLayouts; + for (int i = 0; i < fontSizes; ++i) { + for (int j = 0; j < 4; ++j) { + QTextLayout* newTextLayout = new QTextLayout(); + newTextLayout->setText(layoutText); + QList<QTextLayout::FormatRange> formatRanges; + QTextLayout::FormatRange formatRange; + + formatRange.format.setFont(QFont()); + formatRange.format.setFontPointSize(i + 5); + + switch (j) { + case 0: + formatRange.format.setFontWeight(QFont::Normal); + formatRange.format.setFontItalic(false); + break; + case 1: + formatRange.format.setFontWeight(QFont::Bold); + formatRange.format.setFontItalic(false); + break; + case 2: + formatRange.format.setFontWeight(QFont::Bold); + formatRange.format.setFontItalic(true); + break; + case 3: + formatRange.format.setFontWeight(QFont::Normal); + formatRange.format.setFontItalic(true); + break; + } + + formatRange.format.setVerticalAlignment( QTextCharFormat::AlignSuperScript); + + formatRange.start = 0; + formatRange.length = layoutText.size(); + formatRanges << formatRange; + newTextLayout->setAdditionalFormats(formatRanges); + + textLayouts.push_front(newTextLayout); + } + } + + // This loop would crash before fix for QTBUG-53911 + foreach (QTextLayout *textLayout, textLayouts) { + textLayout->beginLayout(); + while (textLayout->createLine().isValid()); + textLayout->endLayout(); + } + + qDeleteAll(textLayouts); +} + QTEST_MAIN(tst_QTextLayout) #include "tst_qtextlayout.moc" |