summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRobin Burchell <robin+qt@viroteck.net>2012-03-05 15:05:16 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-12 01:50:20 +0100
commit70cb55bc6df486b51addf0c622bf3e77d324abf5 (patch)
tree4a1cfaee6381a18922d482c90d4a0c43d38561e2 /src
parenta71e12b1709557e9a7263dbf191ec28689ccd992 (diff)
Force properties to be applied in the order in which they are specified.
Previously, property setting was randomized in order, which means that things like: qproperty-foo: 4; qproperty-bar: 5; where foo may affect bar worked by chance - or not at all - depending on the hash function. Change-Id: Ifb9813ee72842cefb278cbedb644f24b91113f3f Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 5c0ee254d4..7a0cc09452 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -2498,7 +2498,13 @@ void QStyleSheetStyle::setGeometry(QWidget *w)
void QStyleSheetStyle::setProperties(QWidget *w)
{
+ // we have two data structures here: a hash of property -> value for lookup,
+ // and a vector giving properties in the order they are specified.
+ //
+ // this means we only set a property once (thanks to the hash) but we set
+ // properties in the order they are specified.
QHash<QString, QVariant> propertyHash;
+ QVector<QString> properties;
QVector<Declaration> decls = declarations(styleRules(w), QString());
// run through the declarations in order
@@ -2535,10 +2541,17 @@ void QStyleSheetStyle::setProperties(QWidget *w)
#endif
default: v = decl.d->values.at(0).variant; break;
}
+
+ if (propertyHash.contains(property)) {
+ // we're ignoring the original appearance of this property
+ properties.remove(properties.indexOf(property));
+ }
+
propertyHash[property] = v;
+ properties.append(property);
}
- // apply the values
- const QList<QString> properties = propertyHash.keys();
+
+ // apply the values from left to right order
for (int i = 0; i < properties.count(); i++) {
const QString &property = properties.at(i);
w->setProperty(property.toLatin1(), propertyHash[property]);