summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlbasicscript.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-10-16 06:13:32 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-10-16 06:13:32 (GMT)
commit5d261870c2c208027fd4fd90d66b2e734235ba3d (patch)
tree5c7f81e7d8dc7a0f8158ab19d6fb2539d01e9d6a /src/declarative/qml/qmlbasicscript.cpp
parent8eec0b69e303d10582d04784a0bb200418272c4d (diff)
downloadQt-5d261870c2c208027fd4fd90d66b2e734235ba3d.zip
Qt-5d261870c2c208027fd4fd90d66b2e734235ba3d.tar.gz
Qt-5d261870c2c208027fd4fd90d66b2e734235ba3d.tar.bz2
Add binding assignment warnings
Diffstat (limited to 'src/declarative/qml/qmlbasicscript.cpp')
-rw-r--r--src/declarative/qml/qmlbasicscript.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/declarative/qml/qmlbasicscript.cpp b/src/declarative/qml/qmlbasicscript.cpp
index a0d749f..b7aac54 100644
--- a/src/declarative/qml/qmlbasicscript.cpp
+++ b/src/declarative/qml/qmlbasicscript.cpp
@@ -181,19 +181,24 @@ static QVariant fetch_value(QObject *o, int idx, int type)
break;
default:
{
+ // 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 (QmlMetaType::isObject(type)) {
// NOTE: This assumes a cast to QObject does not alter the
// object pointer
QObject *val = 0;
void *args[] = { &val, 0 };
QMetaObject::metacall(o, QMetaObject::ReadProperty, idx, args);
- return QVariant::fromValue(val);
+ if (!val) return QVariant(type, &val);
+ else return QVariant::fromValue(val);
} else {
QVariant var = o->metaObject()->property(idx).read(o);
if (QmlMetaType::isObject(var.userType())) {
QObject *obj = 0;
obj = *(QObject **)var.data();
- var = QVariant::fromValue(obj);
+ if (!obj) var = QVariant(var.userType(), &obj);
+ else var = QVariant::fromValue(obj);
}
return var;
}
@@ -665,7 +670,7 @@ QVariant QmlBasicScript::run(QmlContext *context, QObject *me)
case ScriptInstruction::FetchConstant:
{
QVariant o = stack.pop();
- QObject *obj = qvariant_cast<QObject *>(o);
+ QObject *obj = *(QObject **)o.constData();
stack.push(fetch_value(obj, instr.constant.idx, instr.constant.type));
if (obj && instr.constant.notify != 0)