aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlbinding.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2016-07-14 12:09:23 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2016-07-25 09:26:38 +0000
commit007ae316a62670eeff8b08526fad9110fff0bbd4 (patch)
tree142aa98565878d394935e85b91edf499279c9d8a /src/qml/qml/qqmlbinding.cpp
parent4c1a51006e5936dc69e3373539787120092f6719 (diff)
QML: Unify property reads/writes and use accessors
Pass property reads/writes through utility functions in QQmlProperty, which in turn will try to use accessors when available (and no interceptors have to be called). Change-Id: I60ecfc202b6024bfe4a33206a46299787b152546 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlbinding.cpp')
-rw-r--r--src/qml/qml/qqmlbinding.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp
index 9737dfdd6b..10d16a8a12 100644
--- a/src/qml/qml/qqmlbinding.cpp
+++ b/src/qml/qml/qqmlbinding.cpp
@@ -157,7 +157,7 @@ void QQmlBinding::setNotifyOnValueChanged(bool v)
QQmlJavaScriptExpression::setNotifyOnValueChanged(v);
}
-void QQmlBinding::update(QQmlPropertyPrivate::WriteFlags flags)
+void QQmlBinding::update(QQmlPropertyData::WriteFlags flags)
{
if (!enabledFlag() || !context() || !context()->isValid())
return;
@@ -181,6 +181,9 @@ void QQmlBinding::update(QQmlPropertyPrivate::WriteFlags flags)
QV4::ScopedFunctionObject f(scope, m_function.value());
Q_ASSERT(f);
+ if (canUseAccessor())
+ flags.setFlag(QQmlPropertyData::BypassInterceptor);
+
QQmlBindingProfiler prof(ep->profiler, this, f);
doUpdate(this, watcher, flags, scope, f);
@@ -197,7 +200,7 @@ class QQmlBindingBinding: public QQmlBinding
{
protected:
void doUpdate(QQmlBinding *binding, const DeleteWatcher &,
- QQmlPropertyPrivate::WriteFlags flags, QV4::Scope &,
+ QQmlPropertyData::WriteFlags flags, QV4::Scope &,
const QV4::ScopedFunctionObject &) Q_DECL_OVERRIDE Q_DECL_FINAL
{
QQmlPropertyData pd = getPropertyData();
@@ -216,7 +219,7 @@ class GenericBinding: public QQmlBinding
{
protected:
void doUpdate(QQmlBinding *binding, const DeleteWatcher &watcher,
- QQmlPropertyPrivate::WriteFlags flags, QV4::Scope &scope,
+ QQmlPropertyData::WriteFlags flags, QV4::Scope &scope,
const QV4::ScopedFunctionObject &f) Q_DECL_OVERRIDE Q_DECL_FINAL
{
auto ep = QQmlEnginePrivate::get(scope.engine);
@@ -251,7 +254,7 @@ protected:
// Returns true if successful, false if an error description was set on expression
Q_ALWAYS_INLINE bool write(const QV4::Value &result, bool isUndefined,
- QQmlPropertyPrivate::WriteFlags flags)
+ QQmlPropertyData::WriteFlags flags)
{
QQmlPropertyData pd = getPropertyData();
int propertyType = StaticPropType; // If the binding is specialized to a type, the if and switch below will be constant-folded.
@@ -298,22 +301,15 @@ protected:
}
template <typename T>
- Q_ALWAYS_INLINE bool doStore(T value, const QQmlPropertyData &pd, QQmlPropertyPrivate::WriteFlags flags) const
+ Q_ALWAYS_INLINE bool doStore(T value, const QQmlPropertyData &pd, QQmlPropertyData::WriteFlags flags) const
{
void *o = &value;
- if (pd.hasAccessors() && canUseAccessor()) {
- pd.accessors->write(m_target.data(), o);
- } else {
- int status = -1;
- void *argv[] = { o, 0, &status, &flags };
- QMetaObject::metacall(targetObject(), QMetaObject::WriteProperty, pd.coreIndex, argv);
- }
- return true;
+ return pd.writeProperty(targetObject(), o, flags);
}
};
Q_NEVER_INLINE bool QQmlBinding::slowWrite(const QQmlPropertyData &core, const QV4::Value &result,
- bool isUndefined, QQmlPropertyPrivate::WriteFlags flags)
+ bool isUndefined, QQmlPropertyData::WriteFlags flags)
{
QQmlEngine *engine = context()->engine;
QV8Engine *v8engine = QQmlEnginePrivate::getV8Engine(engine);
@@ -458,7 +454,7 @@ void QQmlBinding::refresh()
update();
}
-void QQmlBinding::setEnabled(bool e, QQmlPropertyPrivate::WriteFlags flags)
+void QQmlBinding::setEnabled(bool e, QQmlPropertyData::WriteFlags flags)
{
setEnabledFlag(e);
setNotifyOnValueChanged(e);