summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2014-12-15 13:50:11 +0100
committerKonstantin Ritt <ritt.ks@gmail.com>2014-12-15 21:02:12 +0100
commit19bb9aa9e51e48043544fd7edf5abfda67955a4b (patch)
tree69860b0a7e408d2d2a22e1309e3cccd34374d81c /tests/auto/gui
parent21101d9c52d2b7c6471f9814c9bff5aa87e22afc (diff)
Fix possibly corrupted log clusters when using custom tab stops
The calculateTabWidth() can trigger shaping of the item, which can cause the layout data to be reallocated, so we need to update the local pointers to it, like we do when we explicitly invoke the shaper. [ChangeLog][Text] Fixed problems with text layout when using custom tab stops. Task-number: QTBUG-43126 Change-Id: Ifaeeeb4bfb1a55e6638b12b444f53d2679d3d1e6 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
index a9a358711b..4b2970cd17 100644
--- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
@@ -116,6 +116,7 @@ private slots:
void boundingRectForSetLineWidth();
void glyphLessItems();
void justifyTrailingSpaces();
+ void layoutWithCustomTabStops();
// QTextLine stuff
void setNumColumnsWrapAtWordBoundaryOrAnywhere();
@@ -2050,5 +2051,38 @@ void tst_QTextLayout::nbsp()
layout.endLayout();
}
+void tst_QTextLayout::layoutWithCustomTabStops()
+{
+ QScopedPointer<QTextLayout> textLayout(new QTextLayout);
+ QList<QTextOption::Tab> tabStops;
+
+ const int tabWidth = 18;
+ const int maxTabPos = 2500;
+ for (int tabPos = tabWidth; tabPos < maxTabPos; tabPos += tabWidth)
+ tabStops << QTextOption::Tab(tabPos, QTextOption::LeftTab);
+
+ QTextOption textOption;
+ textOption.setTabs(tabStops);
+ textLayout->setTextOption(textOption);
+
+ textLayout->setText(QStringLiteral("\ta aa aa aa aa aa aa"));
+
+ textLayout->beginLayout();
+ textLayout->createLine();
+ textLayout->endLayout();
+
+ qreal shortWidth = textLayout->maximumWidth();
+
+ textLayout->setText(QStringLiteral("\ta aa aa aa aa aa aa aa aa aa aa aa aa a"));
+
+ textLayout->beginLayout();
+ textLayout->createLine();
+ textLayout->endLayout();
+
+ qreal longWidth = textLayout->maximumWidth();
+
+ QVERIFY(longWidth > shortWidth);
+}
+
QTEST_MAIN(tst_QTextLayout)
#include "tst_qtextlayout.moc"