aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/v8
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/v8
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/v8')
-rw-r--r--src/qml/qml/v8/qv8qobjectwrapper.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/qml/qml/v8/qv8qobjectwrapper.cpp b/src/qml/qml/v8/qv8qobjectwrapper.cpp
index 0c656631f7..600d98db5a 100644
--- a/src/qml/qml/v8/qv8qobjectwrapper.cpp
+++ b/src/qml/qml/v8/qv8qobjectwrapper.cpp
@@ -596,8 +596,11 @@ static inline void StoreProperty(QV8Engine *engine, QObject *object, QQmlPropert
if (value->ToObject()->GetHiddenValue(engine->bindingFlagKey()).IsEmpty()) {
if (!property->isVarProperty() && property->propType != qMetaTypeId<QJSValue>()) {
// assigning a JS function to a non var or QJSValue property or is not allowed.
- QString error = QLatin1String("Cannot assign JavaScript function to ") +
- QLatin1String(QMetaType::typeName(property->propType));
+ QString error = QLatin1String("Cannot assign JavaScript function to ");
+ if (!QMetaType::typeName(property->propType))
+ error += QLatin1String("[unknown property type]");
+ else
+ error += QLatin1String(QMetaType::typeName(property->propType));
v8::ThrowException(v8::Exception::Error(engine->toString(error)));
return;
}
@@ -653,8 +656,11 @@ static inline void StoreProperty(QV8Engine *engine, QObject *object, QQmlPropert
} else if (!newBinding && property->propType == qMetaTypeId<QJSValue>()) {
PROPERTY_STORE(QJSValue, engine->scriptValueFromInternal(value));
} else if (value->IsUndefined()) {
- QString error = QLatin1String("Cannot assign [undefined] to ") +
- QLatin1String(QMetaType::typeName(property->propType));
+ QString error = QLatin1String("Cannot assign [undefined] to ");
+ if (!QMetaType::typeName(property->propType))
+ error += QLatin1String("[unknown property type]");
+ else
+ error += QLatin1String(QMetaType::typeName(property->propType));
v8::ThrowException(v8::Exception::Error(engine->toString(error)));
} else if (value->IsFunction()) {
// this is handled by the binding creation above