newBinding = new QQmlBinding(value, object, callingQmlContext, frame.source,
qmlSourceCoordinate(frame.line), qmlSourceCoordinate(frame.column));
newBinding->setTarget(object, *property, callingQmlContext);
- newBinding->setEvaluateFlags(newBinding->evaluateFlags() |
- QQmlBinding::RequiresThisObject);
}
}
{
}
-void QQmlBinding::setEvaluateFlags(EvaluateFlags flags)
-{
- setRequiresThisObject(flags & RequiresThisObject);
-}
-
-QQmlBinding::EvaluateFlags QQmlBinding::evaluateFlags() const
-{
- return requiresThisObject()?RequiresThisObject:None;
-}
-
void QQmlBinding::setNotifyOnValueChanged(bool v)
{
QQmlJavaScriptExpression::setNotifyOnValueChanged(v);
public QQmlAbstractBinding
{
public:
- enum EvaluateFlag { None = 0x00, RequiresThisObject = 0x01 };
- Q_DECLARE_FLAGS(EvaluateFlags, EvaluateFlag)
-
QQmlBinding(const QString &, QObject *, QQmlContext *);
QQmlBinding(const QQmlScriptString &, QObject *, QQmlContext *);
QQmlBinding(const QString &, QObject *, QQmlContextData *);
void setTarget(QObject *, const QQmlPropertyData &, QQmlContextData *);
QQmlProperty property() const;
- void setEvaluateFlags(EvaluateFlags flags);
- EvaluateFlags evaluateFlags() const;
-
void setNotifyOnValueChanged(bool);
// Inherited from QQmlAbstractExpression
m_ctxt.setFlag2Value(v);
}
-Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlBinding::EvaluateFlags)
-
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QQmlBinding*)
QV4::Scope scope(v4);
QV4::ScopedValue result(scope, QV4::Primitive::undefinedValue());
QV4::ExecutionContext *ctx = v4->current;
- callData->thisObject = ep->v8engine()->global();
- if (scopeObject() && requiresThisObject()) {
+ callData->thisObject = v4->globalObject;
+ if (scopeObject()) {
QV4::ScopedValue value(scope, QV4::QObjectWrapper::wrap(ctx->engine, scopeObject()));
if (value->isObject())
callData->thisObject = value;
QV4::ReturnedValue evaluate(QQmlContextData *, const QV4::ValueRef function, bool *isUndefined);
QV4::ReturnedValue evaluate(QQmlContextData *, const QV4::ValueRef function, QV4::CallData *callData, bool *isUndefined);
- inline bool requiresThisObject() const;
- inline void setRequiresThisObject(bool v);
inline bool notifyOnValueChanged() const;
void setNotifyOnValueChanged(bool v);
QPointerValuePair<VTable, QQmlDelayedError> m_vtable;
// We store some flag bits in the following flag pointers.
- // m_scopeObject:flag1 - requiresThisObject
// activeGuards:flag1 - notifyOnValueChanged
// activeGuards:flag2 - useSharedContext
QBiPointer<QObject, DeleteWatcher> m_scopeObject;
return *_w == 0;
}
-bool QQmlJavaScriptExpression::requiresThisObject() const
-{
- return m_scopeObject.flag();
-}
-
-void QQmlJavaScriptExpression::setRequiresThisObject(bool v)
-{
- m_scopeObject.setFlagValue(v);
-}
-
bool QQmlJavaScriptExpression::notifyOnValueChanged() const
{
return activeGuards.flag();
newBinding = new QQmlBinding(value, reference->object, context,
frame.source, qmlSourceCoordinate(frame.line), qmlSourceCoordinate(frame.column));
newBinding->setTarget(reference->object, cacheData, context);
- newBinding->setEvaluateFlags(newBinding->evaluateFlags() |
- QQmlBinding::RequiresThisObject);
}
QQmlAbstractBinding *oldBinding =
--- /dev/null
+import QtQml 2.0
+QtObject {
+ property int value: 1
+ property QtObject subObject: QtObject {
+ property int value: 2
+ property int test: {
+ return this.value;
+ }
+ }
+}
void numberParsing();
void stringParsing();
void qtbug_32801();
+ void thisObject();
private:
// static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter);
QVERIFY(QMetaObject::invokeMethod(obj.data(), "emitTestSignal"));
}
+void tst_qqmlecmascript::thisObject()
+{
+ QQmlComponent component(&engine, testFileUrl("thisObject.qml"));
+ QObject *object = component.create();
+ QVERIFY(object);
+ QCOMPARE(qvariant_cast<QObject*>(object->property("subObject"))->property("test").toInt(), 2);
+ delete object;
+}
+
QTEST_MAIN(tst_qqmlecmascript)
#include "tst_qqmlecmascript.moc"