6#include <private/qqmlbinding_p.h>
7#include <private/qqmlglobal_p.h>
8#include <private/qqmlscriptstring_p.h>
9#include <private/qv4functionobject_p.h>
10#include <private/qv4jscall_p.h>
11#include <private/qv4qmlcontext_p.h>
13#include <QtQml/qqmlinfo.h>
15#include <QtCore/qloggingcategory.h>
38 TargetData::WithoutBoundFunction);
40 Q_ASSERT(binding->jsExpression() == js);
41 Q_ASSERT(js->asBinding() == binding);
43 binding->jsExpression()->setNotifyOnValueChanged(
true);
44 binding->jsExpression()->setContext(ctxt);
45 binding->jsExpression()->setScopeObject(
obj);
46 binding->jsExpression()->setupFunction(scope,
function);
56 Q_ASSERT(binding->jsExpression() == js);
57 Q_ASSERT(js->asBinding() == binding);
59 binding->jsExpression()->setNotifyOnValueChanged(
true);
60 binding->jsExpression()->setContext(ctxt);
61 binding->jsExpression()->createQmlBinding(ctxt,
obj,
str,
url, lineNumber);
73 auto scopeObject =
obj ?
obj : scriptPrivate->
scope;
79 if (
engine && ctxtdata && !ctxtdata->urlString().isEmpty() && ctxtdata->typeCompilationUnit()) {
80 url = ctxtdata->urlString();
82 runtimeFunction = ctxtdata->typeCompilationUnit()->runtimeFunctions.at(scriptPrivate->
bindingId);
92 Q_ASSERT(binding->jsExpression() == js);
93 Q_ASSERT(js->asBinding() == binding);
99 js->setupFunction(
qmlContext, runtimeFunction);
109 Q_ASSERT(binding->jsExpression() == js);
110 Q_ASSERT(js->asBinding() == binding);
112 binding->jsExpression()->setNotifyOnValueChanged(
true);
113 binding->jsExpression()->setContext(ctxt);
114 binding->jsExpression()->setScopeObject(
obj);
115 binding->jsExpression()->setupFunction(scope,
function->function());
134 auto binding = asBinding();
135 if (!binding->propertyDataPtr)
147 err.
setDescription(asBinding()->createBindingLoopErrorDescription());
156 binding->evaluateRecursive(bindingObservers);
157 binding->notifyNonRecursive(bindingObservers);
166 static_assert (std::is_trivially_destructible_v<TargetData>);
169 const auto state = hasBoundFunction ? TargetData::HasBoundFunction : TargetData::WithoutBoundFunction;
170 new (&declarativeExtraData) TargetData {
target, targetIndex,
state};
171 errorCallBack = bindingErrorCallback;
185 std::byte *qpropertyPointer =
reinterpret_cast<std::byte *
>(dataPtr);
186 qpropertyPointer +=
type.sizeOf();
192void QQmlPropertyBinding::handleUndefinedAssignment(
QQmlEnginePrivate *ep,
void *dataPtr)
201 propertyData =
data->propertyCache->property(targetIndex().coreIndex());
203 Q_ASSERT(!targetIndex().hasValueTypeIndex());
212 metaType.destruct(dataPtr);
225 bindingData->d_ref() = 0;
227 bindingDataPointer.setObservers(firstObserver.ptr);
229 Q_ASSERT(!bindingData->hasBinding());
230 setIsUndefined(
true);
246 qCWarning(lcQQPropertyBinding) <<
"Resetting " << prop.
name() <<
"due to the binding becoming undefined caused a new binding to be installed\n"
247 <<
"The old binding binding will be abandoned";
252 firstObserver = bindingDataPointer.firstObserver();
255 bindingDataPointer.setObservers(firstObserver.ptr);
271QString QQmlPropertyBinding::createBindingLoopErrorDescription()
280 propertyData =
data->propertyCache->property(targetIndex().coreIndex());
282 Q_ASSERT(!targetIndex().hasValueTypeIndex());
290 auto target = This->target();
295 auto error = This->bindingError();
297 auto location = This->jsExpression()->sourceLocation();
301 auto description =
error.description();
303 description = This->createBindingLoopErrorDescription();
310template<
typename TranslateWithUnit>
313 TranslateWithUnit &&translateWithUnit)
315 return [compilationUnit, translateWithUnit](
QMetaType metaType,
void *dataPtr) ->
bool {
319 QVariant resultVariant(translateWithUnit(compilationUnit));
320 if (metaType != QMetaType::fromType<QString>())
321 resultVariant.
convert(metaType);
323 const bool hasChanged = !metaType.equals(resultVariant.
constData(), dataPtr);
324 metaType.destruct(dataPtr);
325 metaType.construct(dataPtr, resultVariant.
constData());
338 return compilationUnit->bindingValueAsString(binding);
370 QV4::Heap::MemberData *
args =
b->boundArgs();
375 thisObject = &
b->d()->boundThis;
QV4::ExecutionEngine * handle() const
qsizetype size() const noexcept
friend class QPropertyBindingPrivatePtr
QMetaType valueMetaType() const
QPropertyObserverPointer takeObservers()
static constexpr size_t getSizeEnsuringAlignment()
void prependObserver(QPropertyObserverPointer observer)
QUntypedPropertyData * propertyDataPtr
static QQmlRefPointer< QQmlContextData > get(QQmlContext *context)
The QQmlContext class defines a context within a QML engine.
bool isValid() const
Returns whether the context is valid.
QQmlEngine * engine() const
Return the context's QQmlEngine, or \nullptr if the context has no QQmlEngine or the QQmlEngine was d...
static QQmlData * get(QObjectPrivate *priv, bool create)
void warning(const QQmlError &)
static QQmlEnginePrivate * get(QQmlEngine *e)
The QQmlEngine class provides an environment for instantiating QML components.
The QQmlError class encapsulates a QML error.
void setObject(QObject *)
Sets the nearest object where this error occurred.
void setColumn(int)
Sets the error column number.
void setLine(int)
Sets the error line number.
void setDescription(const QString &)
Sets the error description.
void setUrl(const QUrl &)
Sets the url for the file that caused this error.
QObject * scopeObject() const
QV4::ReturnedValue evaluate(bool *isUndefined)
QQmlEngine * engine() const
QQmlRefPointer< QQmlContextData > context() const
virtual QQmlSourceLocation sourceLocation() const
QTaggedPointer< QQmlDelayedError, Tag > m_error
QV4::ReturnedValue evaluate(bool *isUndefined)
QV4::PersistentValue m_boundFunction
void expressionChanged() override
friend class QQmlPropertyBindingJS
static QUntypedPropertyBinding createFromBoundFunction(const QQmlPropertyData *pd, QV4::BoundFunction *function, QObject *obj, const QQmlRefPointer< QQmlContextData > &ctxt, QV4::ExecutionContext *scope, QObject *target, QQmlPropertyIndex targetIndex)
static QUntypedPropertyBinding createFromCodeString(const QQmlPropertyData *property, const QString &str, QObject *obj, const QQmlRefPointer< QQmlContextData > &ctxt, const QString &url, quint16 lineNumber, QObject *target, QQmlPropertyIndex targetIndex)
QQmlPropertyBindingJS * jsExpression()
static QUntypedPropertyBinding create(const QQmlPropertyData *pd, QV4::Function *function, QObject *obj, const QQmlRefPointer< QQmlContextData > &ctxt, QV4::ExecutionContext *scope, QObject *target, QQmlPropertyIndex targetIndex)
static QUntypedPropertyBinding createFromScriptString(const QQmlPropertyData *property, const QQmlScriptString &script, QObject *obj, QQmlContext *ctxt, QObject *target, QQmlPropertyIndex targetIndex)
QMetaType propType() const
static QQmlProperty restore(QObject *, const QQmlPropertyData &, const QQmlPropertyData *, const QQmlRefPointer< QQmlContextData > &)
The QQmlProperty class abstracts accessing properties on objects created from QML.
QMetaType propertyMetaType() const
Returns the metatype of the property.
bool isResettable() const
Returns true if the property is resettable, otherwise false.
bool reset() const
Resets the property and returns true if the property is resettable.
The QQmlScriptString class encapsulates a script and its context.
static QUntypedPropertyBinding Q_QML_PRIVATE_EXPORT create(const QQmlPropertyData *pd, const QQmlRefPointer< QV4::ExecutableCompilationUnit > &compilationUnit, const QV4::CompiledData::Binding *binding)
QString translate() const
T * data()
Returns a pointer to the shared data object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool convert(QMetaType type)
Casts the variant to the requested type, targetType.
const void * constData() const
static constexpr quintptr BindingBit
Combined button and popup list for selecting options.
BindingEvaluationState * suspendCurrentBindingStatus()
void restoreBindingStatus(BindingEvaluationState *status)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction function
DBusConnection const char DBusError * error
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
const QBindingStorage * qGetBindingStorage(const QObject *o)
GLboolean GLboolean GLboolean b
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
QQmlEngine * qmlEngine(const QObject *obj)
QQmlContext * qmlContext(const QObject *obj)
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
static QtPrivate::QPropertyBindingData * bindingDataFromPropertyData(QUntypedPropertyData *dataPtr, QMetaType type)
auto qQmlTranslationPropertyBindingCreateBinding(const QQmlRefPointer< QV4::ExecutableCompilationUnit > &compilationUnit, TranslateWithUnit &&translateWithUnit)
const QtPrivate::BindingFunctionVTable * bindingFunctionVTableForQQmlPropertyBinding(QMetaType type)
Int aligned(Int v, Int byteAlign)
#define QStringLiteral(str)
QUrl url("example.com")
[constructor-url-reference]
obj metaObject() -> className()
ExecutionContext * rootContext() const
CallData * callData(const Scope &scope, const FunctionObject *f=nullptr) const
static Heap::QmlContext * create(QV4::ExecutionContext *parent, QQmlRefPointer< QQmlContextData > context, QObject *scopeObject)