69 lines
2.5 KiB
Diff
69 lines
2.5 KiB
Diff
From: Debian Qt/KDE Maintainers <debian-qt-kde@lists.debian.org>
|
|
Date: Sat, 14 May 2022 17:41:00 +0800
|
|
Subject: fix recursion crash when calling setStyleSheet with
|
|
qproperty-styleSheet
|
|
|
|
When calling setStyleSheet with property qproperty-styleSheet,
|
|
QStyleSheetStyle::polish will call QStyleSheetStyle::setProperties,
|
|
and then QStyleSheetStyle::setProperties goes on to call setProperty.
|
|
Because there is property qproperty-styleSheet, it will update
|
|
stylesheet by calling QStyleSheetStyle::polish.
|
|
This causes the recursive call to crash.
|
|
Origin: upstream, https://code.qt.io/cgit/qt/qtbase.git/commit/?id=e9cdcc7cb314586a
|
|
Last-Update: 2021-11-13
|
|
---
|
|
src/widgets/styles/qstylesheetstyle.cpp | 3 +++
|
|
.../styles/qstylesheetstyle/tst_qstylesheetstyle.cpp | 18 ++++++++++++++++++
|
|
2 files changed, 21 insertions(+)
|
|
|
|
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
|
|
index 53fff29..f9ab558 100644
|
|
--- a/src/widgets/styles/qstylesheetstyle.cpp
|
|
+++ b/src/widgets/styles/qstylesheetstyle.cpp
|
|
@@ -2640,6 +2640,9 @@ void QStyleSheetStyle::setProperties(QWidget *w)
|
|
default: v = decl.d->values.at(0).variant; break;
|
|
}
|
|
|
|
+ if (propertyL1 == QByteArray("styleSheet") && value == v)
|
|
+ continue;
|
|
+
|
|
w->setProperty(propertyL1, v);
|
|
}
|
|
}
|
|
diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
|
|
index 26868a7..5d67ce5 100644
|
|
--- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
|
|
+++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
|
|
@@ -94,6 +94,7 @@ private slots:
|
|
void layoutSpacing();
|
|
#endif
|
|
void qproperty();
|
|
+ void qproperty_styleSheet();
|
|
void palettePropagation_data();
|
|
void palettePropagation();
|
|
void fontPropagation_data();
|
|
@@ -678,6 +679,23 @@ void tst_QStyleSheetStyle::qproperty()
|
|
QCOMPARE(pb.isChecked(), false);
|
|
}
|
|
|
|
+void tst_QStyleSheetStyle::qproperty_styleSheet()
|
|
+{
|
|
+ QWidget w;
|
|
+ auto checkBox = new QCheckBox("check", &w);
|
|
+ QString sheet = R"(QCheckBox { qproperty-styleSheet: "QCheckBox { qproperty-text: foobar; }"; })";
|
|
+
|
|
+ QVERIFY(w.property("styleSheet").toString().isEmpty());
|
|
+
|
|
+ w.setStyleSheet(sheet);
|
|
+ QCOMPARE(checkBox->text(), "check");
|
|
+
|
|
+ //recursion crash
|
|
+ w.ensurePolished();
|
|
+ QCOMPARE(w.property("styleSheet").toString(), sheet);
|
|
+ QCOMPARE(checkBox->text(), "foobar");
|
|
+}
|
|
+
|
|
namespace ns {
|
|
class PushButton1 : public QPushButton {
|
|
Q_OBJECT
|