aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/util/qdeclarativepropertymap.cpp
diff options
context:
space:
mode:
authorCharles Yin <charles.yin@nokia.com>2011-09-06 13:54:46 +1000
committerQt by Nokia <qt-info@nokia.com>2011-09-06 10:31:39 +0200
commit0fdd97f613af6ae255e9cd1470ad8d4d67091dd7 (patch)
treeaeed6d854834c97da878743f6a8fbb99ff1bb421 /src/declarative/util/qdeclarativepropertymap.cpp
parent36de9924764c90bd963bf1cdabe170bff3ae8a70 (diff)
more fixes for QTBUG-17868
QDeclarativePropertyCache bypasses the previous fix, need to check the property name when property cache try to create property. Change-Id: Ibccc02df568a8ded3626bb914150ba9ee87d238f Task-number:QTBUG-17868 Reviewed-on: http://codereview.qt.nokia.com/4230 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'src/declarative/util/qdeclarativepropertymap.cpp')
-rw-r--r--src/declarative/util/qdeclarativepropertymap.cpp28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/declarative/util/qdeclarativepropertymap.cpp b/src/declarative/util/qdeclarativepropertymap.cpp
index c9242672c5..fc009a8a36 100644
--- a/src/declarative/util/qdeclarativepropertymap.cpp
+++ b/src/declarative/util/qdeclarativepropertymap.cpp
@@ -58,7 +58,7 @@ public:
protected:
virtual void propertyWritten(int index);
virtual void propertyCreated(int, QMetaPropertyBuilder &);
-
+ virtual int createProperty(const char *, const char *);
private:
QDeclarativePropertyMap *map;
QDeclarativePropertyMapPrivate *priv;
@@ -71,8 +71,19 @@ public:
QDeclarativePropertyMapMetaObject *mo;
QStringList keys;
void emitChanged(const QString &key, const QVariant &value);
+ bool validKeyName(const QString& name);
};
+bool QDeclarativePropertyMapPrivate::validKeyName(const QString& name)
+{
+ //The following strings shouldn't be used as property names
+ return name != QLatin1String("keys")
+ && name != QLatin1String("valueChanged")
+ && name != QLatin1String("QObject")
+ && name != QLatin1String("destroyed")
+ && name != QLatin1String("deleteLater");
+}
+
void QDeclarativePropertyMapPrivate::emitChanged(const QString &key, const QVariant &value)
{
Q_Q(QDeclarativePropertyMap);
@@ -95,6 +106,13 @@ void QDeclarativePropertyMapMetaObject::propertyCreated(int, QMetaPropertyBuilde
priv->keys.append(QString::fromUtf8(b.name()));
}
+int QDeclarativePropertyMapMetaObject::createProperty(const char *name, const char *value)
+{
+ if (!priv->validKeyName(name))
+ return -1;
+ return QDeclarativeOpenMetaObject::createProperty(name, value);
+}
+
/*!
\class QDeclarativePropertyMap
\brief The QDeclarativePropertyMap class allows you to set key-value pairs that can be used in QML bindings.
@@ -181,12 +199,8 @@ QVariant QDeclarativePropertyMap::value(const QString &key) const
void QDeclarativePropertyMap::insert(const QString &key, const QVariant &value)
{
Q_D(QDeclarativePropertyMap);
- //The following strings shouldn't be used as property names
- if (key != QLatin1String("keys")
- && key != QLatin1String("valueChanged")
- && key != QLatin1String("QObject")
- && key != QLatin1String("destroyed")
- && key != QLatin1String("deleteLater")) {
+
+ if (d->validKeyName(key)) {
d->mo->setValue(key.toUtf8(), value);
} else {
qWarning() << "Creating property with name"