diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-12-07 13:20:36 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-12-07 13:20:36 +0100 |
commit | 4ab7deb923237b0186a211b0326217c480e33848 (patch) | |
tree | e277fb616e58e02bb49e0dc62d1ff9a039e8bcdb /src/qml/types | |
parent | c3f03bbff1db14dc5b5436d8aef834512207d498 (diff) | |
parent | bb921064b966efdaabc2245cad21c3d852848a22 (diff) |
Merge remote-tracking branch 'origin/5.6' into dev
Change-Id: Ica75a71062d0613e415f2433c5c22c2e251b37cd
Diffstat (limited to 'src/qml/types')
-rw-r--r-- | src/qml/types/qqmlbind.cpp | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/src/qml/types/qqmlbind.cpp b/src/qml/types/qqmlbind.cpp index bd893bd2f4..45b7edd316 100644 --- a/src/qml/types/qqmlbind.cpp +++ b/src/qml/types/qqmlbind.cpp @@ -50,29 +50,6 @@ QT_BEGIN_NAMESPACE -namespace { - -void validateProperty(QObject *target, const QString &propertyName, QObject *binding) -{ - if (!target) - return; - - const QMetaObject *mo = target->metaObject(); - const int index = mo->indexOfProperty(propertyName.toUtf8()); - if (index == -1) { - qmlInfo(binding) << "Property '" << propertyName << "' does not exist on " << QQmlMetaType::prettyTypeName(target) << "."; - return; - } - - const QMetaProperty mp = mo->property(index); - if (!mp.isWritable()) { - qmlInfo(binding) << "Property '" << propertyName << "' on " << QQmlMetaType::prettyTypeName(target) << " is read-only."; - return; - } -} - -} - class QQmlBindPrivate : public QObjectPrivate { public: @@ -86,8 +63,25 @@ public: QQmlNullableValue<QVariant> value; QQmlProperty prop; QQmlAbstractBinding::Ptr prevBind; + + void validate(QObject *binding) const; }; +void QQmlBindPrivate::validate(QObject *binding) const +{ + if (!obj) + return; + + if (!prop.isValid()) { + qmlInfo(binding) << "Property '" << propName << "' does not exist on " << QQmlMetaType::prettyTypeName(obj) << "."; + return; + } + + if (!prop.isWritable()) { + qmlInfo(binding) << "Property '" << propName << "' on " << QQmlMetaType::prettyTypeName(obj) << " is read-only."; + return; + } +} /*! \qmltype Binding @@ -211,8 +205,8 @@ void QQmlBind::setObject(QObject *obj) } d->obj = obj; if (d->componentComplete) { - validateProperty(d->obj, d->propName, this); d->prop = QQmlProperty(d->obj, d->propName); + d->validate(this); } eval(); } @@ -257,8 +251,8 @@ void QQmlBind::setProperty(const QString &p) } d->propName = p; if (d->componentComplete) { - validateProperty(d->obj, d->propName, this); d->prop = QQmlProperty(d->obj, d->propName); + d->validate(this); } eval(); } @@ -299,8 +293,8 @@ void QQmlBind::componentComplete() Q_D(QQmlBind); d->componentComplete = true; if (!d->prop.isValid()) { - validateProperty(d->obj, d->propName, this); d->prop = QQmlProperty(d->obj, d->propName); + d->validate(this); } eval(); } |