aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/util
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-01-13 10:13:38 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-01-13 12:56:04 +0100
commit315261a809778a8ac37c523741e021d6431ab85e (patch)
treebd97a9c56ae7235e3a4dfa3b953d6d629bdae7a6 /src/qml/util
parenta129c02e7b0d9977eafa66dc191ef185774f461e (diff)
QQmlPropertyMap: Check validity of keys only once
The QQmlPropertyMap should guard the keys before it passes them on to QQmlOpenMetaObject, rather than getting called back through the virtual createProperty() method. Change-Id: Ie02ab02c4e27260222964c708c0f0917c8c6239d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Diffstat (limited to 'src/qml/util')
-rw-r--r--src/qml/util/qqmlpropertymap.cpp11
1 files changed, 2 insertions, 9 deletions
diff --git a/src/qml/util/qqmlpropertymap.cpp b/src/qml/util/qqmlpropertymap.cpp
index 4681cac864..e5fa66aded 100644
--- a/src/qml/util/qqmlpropertymap.cpp
+++ b/src/qml/util/qqmlpropertymap.cpp
@@ -57,7 +57,6 @@ protected:
QVariant propertyWriteValue(int, const QVariant &) override;
void propertyWritten(int index) override;
void propertyCreated(int, QMetaPropertyBuilder &) override;
- int createProperty(const char *, const char *) override;
const QString &propertyName(int index);
@@ -130,13 +129,6 @@ void QQmlPropertyMapMetaObject::propertyCreated(int, QMetaPropertyBuilder &b)
priv->keys.append(QString::fromUtf8(b.name()));
}
-int QQmlPropertyMapMetaObject::createProperty(const char *name, const char *value)
-{
- if (!priv->validKeyName(QString::fromUtf8(name)))
- return -1;
- return QQmlOpenMetaObject::createProperty(name, value);
-}
-
/*!
\class QQmlPropertyMap
\brief The QQmlPropertyMap class allows you to set key-value pairs that can be used in QML bindings.
@@ -207,7 +199,8 @@ QQmlPropertyMap::~QQmlPropertyMap()
void QQmlPropertyMap::clear(const QString &key)
{
Q_D(QQmlPropertyMap);
- d->mo->setValue(key.toUtf8(), QVariant());
+ if (d->validKeyName(key))
+ d->mo->setValue(key.toUtf8(), QVariant());
}
/*!