summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/styles
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@qt.io>2018-10-15 16:39:03 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2019-04-12 14:33:32 +0000
commit21dcb96ddca357a6e8ace4b1c7252ec465e77727 (patch)
tree88fdf6336126ad6176dc60984e38428d7549c5f2 /tests/auto/widgets/styles
parent2593463eafcf8b3cb62dd4f8f9545359336bc005 (diff)
QStyleSheetStyle::repolish: only run on direct children
When re-parenting, some widgets change their children. For example QLabel, when set to rich text, will not update, until receiving a polish call, at which time getting a list of all children recursively and then trying to call functions on them will crash, since the children change in the middle of this operation. Fixes: QTBUG-69204 Fixes: QTBUG-74667 Change-Id: I95dd83ebeed14c017e22552ddd47658ae8a09353 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/widgets/styles')
-rw-r--r--tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
index 0e5c40f1b6..8760ed0373 100644
--- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -48,6 +48,7 @@ public:
private slots:
void init();
void repolish();
+ void repolish_without_crashing();
void numinstances();
void widgetsBeforeAppStyleSheet();
void widgetsAfterAppStyleSheet();
@@ -367,6 +368,26 @@ void tst_QStyleSheetStyle::repolish()
QCOMPARE(BACKGROUND(p1), APPBACKGROUND(p1));
}
+void tst_QStyleSheetStyle::repolish_without_crashing()
+{
+ // This used to crash, QTBUG-69204
+ QMainWindow w;
+ QScopedPointer<QSplitter> splitter1(new QSplitter(w.centralWidget()));
+ QScopedPointer<QSplitter> splitter2(new QSplitter);
+ QScopedPointer<QSplitter> splitter3(new QSplitter);
+ splitter2->addWidget(splitter3.data());
+
+ splitter2->setStyleSheet("color: red");
+ QScopedPointer<QLabel> label(new QLabel);
+ label->setTextFormat(Qt::RichText);
+ splitter3->addWidget(label.data());
+ label->setText("hey");
+
+ splitter1->addWidget(splitter2.data());
+ w.show();
+ QCOMPARE(COLOR(*label), QColor(Qt::red));
+}
+
void tst_QStyleSheetStyle::widgetStyle()
{
qApp->setStyleSheet("");