diff options
author | Charles Yin <charles.yin@nokia.com> | 2011-03-02 01:19:07 (GMT) |
---|---|---|
committer | Charles Yin <charles.yin@nokia.com> | 2011-03-03 04:44:16 (GMT) |
commit | 9c1549371e86c95e08f7fc2e11242de12fb1e1da (patch) | |
tree | c5f1f5ce063df53beac4bf27907b996185d621c1 /src | |
parent | e1d1b65e63223e8705b8df09645f8740ab7fb80d (diff) | |
download | Qt-9c1549371e86c95e08f7fc2e11242de12fb1e1da.zip Qt-9c1549371e86c95e08f7fc2e11242de12fb1e1da.tar.gz Qt-9c1549371e86c95e08f7fc2e11242de12fb1e1da.tar.bz2 |
QDeclarativePropertyMap::keys() cannot be called from qml
Not allow create dynamic properties which are same with existing method (method, signal, slot) names.
Change-Id: I0ae64c8a6a89ef4f7614169088f7c005edad40b0
Task-number:QTBUG-17868
Reviewed-by:Martin Jones
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/util/qdeclarativeopenmetaobject.cpp | 14 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativepropertymap.cpp | 15 |
2 files changed, 21 insertions, 8 deletions
diff --git a/src/declarative/util/qdeclarativeopenmetaobject.cpp b/src/declarative/util/qdeclarativeopenmetaobject.cpp index 0ceda35..8a8d05e 100644 --- a/src/declarative/util/qdeclarativeopenmetaobject.cpp +++ b/src/declarative/util/qdeclarativeopenmetaobject.cpp @@ -289,17 +289,19 @@ void QDeclarativeOpenMetaObject::setValue(const QByteArray &name, const QVariant int id = -1; if (iter == d->type->d->names.end()) { - id = d->type->createProperty(name.constData()) - d->type->d->propertyOffset; + id = createProperty(name.constData(), "") - d->type->d->propertyOffset; } else { id = *iter; } - QVariant &dataVal = d->getData(id); - if (dataVal == val) - return; + if (id >= 0) { + QVariant &dataVal = d->getData(id); + if (dataVal == val) + return; - dataVal = val; - activate(d->object, id + d->type->d->signalOffset, 0); + dataVal = val; + activate(d->object, id + d->type->d->signalOffset, 0); + } } // returns true if this value has been initialized by a call to either value() or setValue() diff --git a/src/declarative/util/qdeclarativepropertymap.cpp b/src/declarative/util/qdeclarativepropertymap.cpp index 1a3e0be..915f027 100644 --- a/src/declarative/util/qdeclarativepropertymap.cpp +++ b/src/declarative/util/qdeclarativepropertymap.cpp @@ -182,7 +182,18 @@ QVariant QDeclarativePropertyMap::value(const QString &key) const void QDeclarativePropertyMap::insert(const QString &key, const QVariant &value) { Q_D(QDeclarativePropertyMap); - d->mo->setValue(key.toUtf8(), value); + //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")) { + d->mo->setValue(key.toUtf8(), value); + } else { + qWarning() << "Creating property with name" + << key + << "is not permitted, conflicts with internal symbols."; + } } /*! @@ -258,7 +269,7 @@ QVariant &QDeclarativePropertyMap::operator[](const QString &key) Q_D(QDeclarativePropertyMap); QByteArray utf8key = key.toUtf8(); if (!d->keys.contains(key)) - d->mo->setValue(utf8key, QVariant()); //force creation -- needed below + insert(key, QVariant());//force creation -- needed below return (*(d->mo))[utf8key]; } |