28QQmlAnyBinding QQmlPropertyToPropertyBinding::create(
29 QQmlEngine *engine,
const QQmlProperty &source,
const QQmlProperty &target)
31 QQmlAnyBinding result;
32 if (target.isBindable()) {
33 if (source.isBindable()) {
34 result = QUntypedPropertyBinding(
new QQmlBindableToBindablePropertyBinding(
35 engine, source.object(), QQmlPropertyPrivate::get(source)->encodedIndex(),
36 target.object(), target.index()));
40 result = QUntypedPropertyBinding(
new QQmlUnbindableToBindablePropertyBinding(
41 engine, source.object(), QQmlPropertyPrivate::get(source)->encodedIndex(),
42 target.object(), target.index()));
46 if (source.isBindable()) {
47 result =
new QQmlBindableToUnbindablePropertyBinding(
48 engine, source.object(), QQmlPropertyPrivate::get(source)->encodedIndex(),
49 target.object(), target.index());
53 result =
new QQmlUnbindableToUnbindablePropertyBinding(
54 engine, source.object(), QQmlPropertyPrivate::get(source)->encodedIndex(),
55 target.object(), target.index());
97 QObject *target = targetObject();
98 if (QQmlData::wasDeleted(target))
101 const QQmlPropertyData *d =
nullptr;
102 QQmlPropertyData vtd;
103 getPropertyData(&d, &vtd);
107 if (Q_UNLIKELY(updatingFlag())) {
108 printBindingLoopError(QQmlPropertyPrivate::restore(target, *d, &vtd,
nullptr));
112 setUpdatingFlag(
true);
114 if (canUseAccessor())
115 flags.setFlag(QQmlPropertyData::BypassInterceptor);
117 QVariant value = m_binding.readSourceValue(
118 [&](
const QMetaObject *sourceMetaObject,
const QMetaProperty &property) {
119 captureProperty(sourceMetaObject, property);
122 QQmlPropertyPrivate::writeValueProperty(target, *d, vtd, value, {}, flags);
123 setUpdatingFlag(
false);
158 const QMetaObject *sourceMetaObject,
const QMetaProperty &sourceProperty)
160 Q_UNUSED(sourceProperty);
166 QUntypedBindable bindable;
167 void *argv[] = { &bindable };
168 sourceMetaObject->metacall(
169 m_binding.sourceObject, QMetaObject::BindableProperty,
170 m_binding.sourcePropertyIndex.coreIndex(), argv);
171 bindable.observe(
this);
172 m_isObserving =
true;
202 QMetaType metaType, QUntypedPropertyData *dataPtr,
void *f)
205 =
reinterpret_cast<QQmlUnbindableToBindablePropertyBinding *>(
207 static_cast<std::byte *>(f) - QPropertyBindingPrivate::getSizeEnsuringAlignment());
210 const QVariant value = self->m_binding.readSourceValue(
211 [self](
const QMetaObject *sourceMetaObject,
const QMetaProperty &property) {
212 Q_UNUSED(sourceMetaObject);
213 self->m_binding.doConnectNotify(self, property);
217 self->m_binding.engine->handle(), value.metaType(), value.constData(),
224 PendingBindingObserverList bindingObservers;
225 evaluateRecursive(bindingObservers);
227 if (
const QPropertyBindingError error = bindingError();
228 Q_UNLIKELY(error.type() == QPropertyBindingError::BindingLoop)) {
229 qmlWarning(m_targetObject)
230 <<
"Binding loop detected for property"
231 << m_targetObject->metaObject()->property(m_targetPropertyIndex.coreIndex()).name();
235 notifyNonRecursive(bindingObservers);
251 QMetaType metaType, QUntypedPropertyData *dataPtr,
void *f)
254 =
reinterpret_cast<QQmlBindableToBindablePropertyBinding *>(
256 static_cast<std::byte *>(f) - QPropertyBindingPrivate::getSizeEnsuringAlignment());
259 const QVariant value = self->m_binding.readSourceValue(
260 [](
const QMetaObject *,
const QMetaProperty &) {});
263 self->m_binding.engine->handle(), value.metaType(), value.constData(),