diff options
Diffstat (limited to 'src/declarative/qml/qdeclarativeobjectscriptclass.cpp')
-rw-r--r-- | src/declarative/qml/qdeclarativeobjectscriptclass.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp index aca01b2..be2be8b 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp @@ -93,6 +93,7 @@ QDeclarativeObjectScriptClass::QDeclarativeObjectScriptClass(QDeclarativeEngine m_destroyId = createPersistentIdentifier(QLatin1String("destroy")); m_toString = scriptEngine->newFunction(tostring); m_toStringId = createPersistentIdentifier(QLatin1String("toString")); + m_valueOfId = createPersistentIdentifier(QLatin1String("valueOf")); } QDeclarativeObjectScriptClass::~QDeclarativeObjectScriptClass() @@ -157,7 +158,8 @@ QDeclarativeObjectScriptClass::queryProperty(QObject *obj, const Identifier &nam lastTNData = 0; if (name == m_destroyId.identifier || - name == m_toStringId.identifier) + name == m_toStringId.identifier || + name == m_valueOfId.identifier) return QScriptClass::HandlesReadAccess; if (!obj) @@ -211,11 +213,15 @@ QDeclarativeObjectScriptClass::property(QObject *obj, const Identifier &name) if (name == m_destroyId.identifier) return Value(scriptEngine, m_destroy); - else if (name == m_toStringId.identifier) + else if (name == m_toStringId.identifier || + name == m_valueOfId.identifier) return Value(scriptEngine, m_toString); - if (lastData && !lastData->isValid()) - return Value(); + if (lastData && !lastData->isValid()) { + QString error = QLatin1String("Cannot access non-existent property \"") + + toString(name) + QLatin1Char('\"'); + return Value(scriptEngine, context()->throwError(error)); + } Q_ASSERT(obj); |