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. Fixes: QTBUG-94448 Pick-to: 5.15 6.2 Change-Id: I79c51192a939b0b62e5b1d0dcc90d38f79e28222 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
parent
0c2ca26cd9
commit
e9cdcc7cb3
@ -2670,6 +2670,9 @@ void QStyleSheetStyle::setProperties(QWidget *w)
|
|||||||
default: v = decl.d->values.at(0).variant; break;
|
default: v = decl.d->values.at(0).variant; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (propertyL1 == QByteArrayView("styleSheet") && value == v)
|
||||||
|
continue;
|
||||||
|
|
||||||
w->setProperty(propertyL1, v);
|
w->setProperty(propertyL1, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,7 @@ private slots:
|
|||||||
void layoutSpacing();
|
void layoutSpacing();
|
||||||
#endif
|
#endif
|
||||||
void qproperty();
|
void qproperty();
|
||||||
|
void qproperty_styleSheet();
|
||||||
void palettePropagation_data();
|
void palettePropagation_data();
|
||||||
void palettePropagation();
|
void palettePropagation();
|
||||||
void fontPropagation_data();
|
void fontPropagation_data();
|
||||||
@ -672,6 +673,23 @@ void tst_QStyleSheetStyle::qproperty()
|
|||||||
QCOMPARE(pb.isChecked(), false);
|
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 {
|
namespace ns {
|
||||||
class PushButton1 : public QPushButton {
|
class PushButton1 : public QPushButton {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user