aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlproperty.cpp
diff options
context:
space:
mode:
authorChris Adams <christopher.adams@nokia.com>2012-05-25 17:23:42 +1000
committerQt by Nokia <qt-info@nokia.com>2012-05-28 02:42:55 +0200
commitf62ab0a3dfaa873bb15cd1526f98f50a17228a9c (patch)
tree483c980f2d17eca24438e47e097bf1034d916daa /src/qml/qml/qqmlproperty.cpp
parent1deba22774e59458dc2e485f1cdf8f5b547d2941 (diff)
Fix crash caused by unregistered enum types
If the enum type isn't registered with Q_ENUMS, the metatype lookup fails, which results in a crash in certain circumstances. This commit ensures that when assigning an undefined value to an unregistered-enum-type property, no crash occurs. Change-Id: I0b539b591c9c9d6262c748300e4f4b6813d4f9a6 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/qml/qml/qqmlproperty.cpp')
-rw-r--r--src/qml/qml/qqmlproperty.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp
index 5ef833cce0..b3f5d5fd88 100644
--- a/src/qml/qml/qqmlproperty.cpp
+++ b/src/qml/qml/qqmlproperty.cpp
@@ -1566,7 +1566,12 @@ bool QQmlPropertyPrivate::writeBinding(QObject *object,
}
writeValueProperty(object, engine, core, QVariant::fromValue(v8engine->scriptValueFromInternal(result)), context, flags);
} else if (isUndefined) {
- expression->delayedError()->error.setDescription(QLatin1String("Unable to assign [undefined] to ") + QLatin1String(QMetaType::typeName(type)));
+ QString errorStr = QLatin1String("Unable to assign [undefined] to ");
+ if (!QMetaType::typeName(type))
+ errorStr += QLatin1String("[unknown property type]");
+ else
+ errorStr += QLatin1String(QMetaType::typeName(type));
+ expression->delayedError()->error.setDescription(errorStr);
return false;
} else if (result->IsFunction()) {
if (!result->ToObject()->GetHiddenValue(v8engine->bindingFlagKey()).IsEmpty())