diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-16 06:13:32 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-16 06:13:32 (GMT) |
commit | 5d261870c2c208027fd4fd90d66b2e734235ba3d (patch) | |
tree | 5c7f81e7d8dc7a0f8158ab19d6fb2539d01e9d6a /src/declarative/qml/qmlexpression.cpp | |
parent | 8eec0b69e303d10582d04784a0bb200418272c4d (diff) | |
download | Qt-5d261870c2c208027fd4fd90d66b2e734235ba3d.zip Qt-5d261870c2c208027fd4fd90d66b2e734235ba3d.tar.gz Qt-5d261870c2c208027fd4fd90d66b2e734235ba3d.tar.bz2 |
Add binding assignment warnings
Diffstat (limited to 'src/declarative/qml/qmlexpression.cpp')
-rw-r--r-- | src/declarative/qml/qmlexpression.cpp | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp index 76ca2c1..3698417 100644 --- a/src/declarative/qml/qmlexpression.cpp +++ b/src/declarative/qml/qmlexpression.cpp @@ -332,20 +332,17 @@ QVariant QmlExpressionPrivate::evalQtScript(QObject *secondaryScope) rv = QVariant::fromValue(list); } } else if (svalue.isObject() && - !svalue.isNumber() && - !svalue.isString() && - !svalue.isDate() && - !svalue.isError() && - !svalue.isFunction() && - !svalue.isNull() && - !svalue.isQMetaObject() && - !svalue.isQObject() && - !svalue.isRegExp()) { - + ep->objectClass->scriptClass(svalue) == ep->objectClass) { QObject *o = svalue.toQObject(); - if (o) - return qVariantFromValue(o); + int type = QMetaType::QObjectStar; + // If the object is null, we extract the predicted type. While this isn't + // 100% reliable, in many cases it gives us better error messages if we + // assign this null-object to an incompatible property + if (!o) type = ep->objectClass->objectType(svalue); + + return QVariant(type, &o); } + if (rv.isNull()) rv = svalue.toVariant(); @@ -452,6 +449,26 @@ void QmlExpression::setTrackChange(bool trackChange) } /*! + Returns the source file URL for this expression. The source location must + have been previously set by calling setSourceLocation(). +*/ +QUrl QmlExpression::sourceFile() const +{ + Q_D(const QmlExpression); + return QUrl(d->data->fileName); +} + +/*! + Returns the source file line number for this expression. The source location + must have been previously set by calling setSourceLocation(). +*/ +int QmlExpression::lineNumber() const +{ + Q_D(const QmlExpression); + return d->data->line; +} + +/*! Set the location of this expression to \a line of \a fileName. This information is used by the script engine. */ |