diff options
author | Matthew Vogt <matthew.vogt@nokia.com> | 2012-05-15 16:56:40 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-21 00:17:37 +0200 |
commit | a96705e349c51215b6e451147b4c2de49ba5a107 (patch) | |
tree | 67898969e15f92e95ccfc97a3ce8c4458a8887e7 /src/qml/qml/v8/qv8qobjectwrapper.cpp | |
parent | 5821f91abb348ac8d8ad84846b504c5629d2eed8 (diff) |
Allow the existence of a VME metaobject to be asserted
Test for the existence of a VME metaobject. Otherwise, assertion of
a static cast result is not meaningful.
Change-Id: Ic9e9c38e5dce65c41d20e405c33e179334c37b00
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'src/qml/qml/v8/qv8qobjectwrapper.cpp')
-rw-r--r-- | src/qml/qml/v8/qv8qobjectwrapper.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/qml/qml/v8/qv8qobjectwrapper.cpp b/src/qml/qml/v8/qv8qobjectwrapper.cpp index 15d7b1fca8..95e2be7584 100644 --- a/src/qml/qml/v8/qv8qobjectwrapper.cpp +++ b/src/qml/qml/v8/qv8qobjectwrapper.cpp @@ -533,7 +533,9 @@ v8::Handle<v8::Value> QV8QObjectWrapper::GetProperty(QV8Engine *engine, QObject if (result->isFunction() && !result->isVMEProperty()) { if (result->isVMEFunction()) { - return ((QQmlVMEMetaObject *)(object->metaObject()))->vmeMethod(result->coreIndex); + QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(object); + Q_ASSERT(vmemo); + return vmemo->vmeMethod(result->coreIndex); } else if (result->isV8Function()) { return MethodClosure::createWithGlobal(engine, object, objectHandle, result->coreIndex); } else if (result->isSignalHandler()) { @@ -571,8 +573,8 @@ v8::Handle<v8::Value> QV8QObjectWrapper::GetProperty(QV8Engine *engine, QObject ep->captureProperty(object, result->coreIndex, result->notifyIndex); if (result->isVMEProperty()) { - typedef QQmlVMEMetaObject VMEMO; - VMEMO *vmemo = const_cast<VMEMO *>(static_cast<const VMEMO *>(object->metaObject())); + QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(object); + Q_ASSERT(vmemo); return vmemo->vmeProperty(result->coreIndex); } else if (result->isDirect()) { return LoadProperty<ReadAccessor::Direct>(engine, object, *result, 0); @@ -622,7 +624,9 @@ static inline void StoreProperty(QV8Engine *engine, QObject *object, QQmlPropert if (!newBinding && property->isVMEProperty()) { // allow assignment of "special" values (null, undefined, function) to var properties - static_cast<QQmlVMEMetaObject *>(const_cast<QMetaObject *>(object->metaObject()))->setVMEProperty(property->coreIndex, value); + QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(object); + Q_ASSERT(vmemo); + vmemo->setVMEProperty(property->coreIndex, value); return; } @@ -660,7 +664,9 @@ static inline void StoreProperty(QV8Engine *engine, QObject *object, QQmlPropert } else if (property->propType == QMetaType::QString && value->IsString()) { PROPERTY_STORE(QString, engine->toString(value->ToString())); } else if (property->isVMEProperty()) { - static_cast<QQmlVMEMetaObject *>(const_cast<QMetaObject *>(object->metaObject()))->setVMEProperty(property->coreIndex, value); + QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(object); + Q_ASSERT(vmemo); + vmemo->setVMEProperty(property->coreIndex, value); } else { QVariant v; if (property->isQList()) |