6#include <private/qqmlnullablevalue_p.h>
7#include <private/qqmlproperty_p.h>
8#include <private/qqmlbinding_p.h>
9#include <private/qqmlmetatype_p.h>
10#include <private/qqmlvmemetaobject_p.h>
11#include <private/qv4persistent_p.h>
19#include <QtCore/qfile.h>
20#include <QtCore/qdebug.h>
21#include <QtCore/qtimer.h>
22#include <QtCore/qloggingcategory.h>
23#include <private/qqmlanybinding_p.h>
24#include <private/qv4qmlcontext_p.h>
25#include <private/qqmlcomponent_p.h>
27#include <private/qobject_p.h>
56 silentDestroy(oldKind);
76 silentDestroy(oldKind);
113 silentDestroy(oldKind);
120 silentDestroy(oldKind);
127 silentDestroy(oldKind);
423 if (
v &&
d->componentComplete)
459 if (
d->obj &&
d->when) {
472 if (
auto abstractBinding = potentialWhenBinding.asAbstractBinding()) {
475 const auto boolType = QMetaType::fromType<bool>();
482 if (
d->componentComplete) {
529 if (!
d->propName.isEmpty() &&
d->when) {
537 if (
d->componentComplete) {
557 if (!
d->lastIsTarget)
560 return d->entries.last().current.variant;
610 if (!
d->componentComplete)
613 d->delayedValues.reset();
617 d->buildBindEntries(
this,
nullptr);
619 if (
d->lastIsTarget) {
620 d->entries.append(std::move(oldEntries.
last()));
664 if (
d->restoreBinding)
682 d->targetEntry()->setTarget(
this,
p);
687 if (
Q_UNLIKELY(lcBindingRemoval().isInfoEnabled())) {
693 q,
SLOT(targetValueChanged()));
696 p.connectNotifySignal(
q,
SLOT(targetValueChanged()));
705 d->componentComplete =
false;
714 switch (binding->
type()) {
722 prop, compilationUnit->bindingValueAsString(binding), scopeObject,
723 contextData, compilationUnit->finalUrlString(), binding->
location.
line());
725 QV4::Scope scope(contextData->engine()->handle());
730 prop, compilationUnit->runtimeFunctions.at(
id), scopeObject, contextData,
747 const QString propertyName = propertyPrefix
750 switch (binding->
type()) {
753 const QString pre = propertyName + u
'.';
770 if (!
entry.prop.isValid()) {
789 qmlWarning(
q).nospace() <<
"Unknown name " << propertyName
790 <<
". The binding is ignored.";
803 switch (binding->
type()) {
819 bindingTarget, binding, compilationUnit, contextData,
q);
826 setVariant(compilationUnit->bindingValueAsString(binding));
829 setVariant(compilationUnit->bindingValueAsNumber(binding));
852 onDelayedValueChanged(delayedName);
865 else if (
pending.contains(delayedName))
869 (*delayedValues)[pendingName].setValue(std::move(
pending));
881 const int delayedIndex = delayedName.toInt(&
ok);
886 (*delayedValues)[pendingName].setValue(
QStringList());
892 if (
data && !
data->deferredData.isEmpty()) {
906 deferredState->push_back(std::move(constructionState));
915 data->releaseDeferredData();
916 if (!deferredState->empty())
926 d->buildBindEntries(
this, &deferredState);
927 d->componentComplete =
true;
928 if (!
d->propName.isEmpty() ||
d->obj) {
930 if (!
target->prop.isValid())
938void QQmlBind::prepareEval()
944 d->pendingEval =
true;
958 d->pendingEval =
false;
959 if (!
d->componentComplete)
968 switch (
entry.previousKind) {
970 if (
d->restoreBinding) {
977 if (
d->restoreValue) {
982 *
entry.previous.v4Value.valueRef());
987 if (
d->restoreValue) {
1003 entry.previousKind =
entry.previous.set(std::move(prevBind),
entry.previousKind);
1007 auto propData = propPriv->core;
1008 if (!propPriv->valueTypeData.isValid() && propData.isVarProperty()) {
1011 auto retVal = vmemo->
vmeProperty(propData.coreIndex());
1029 d->writingProperty =
true;
1032 if (!
entry.prop.isValid())
1034 switch (
entry.currentKind) {
1045 propPriv->core.coreIndex(), *
entry.current.v4Value.valueRef());
1052 d->writingProperty =
false;
1055void QQmlBind::targetValueChanged()
1058 if (
d->writingProperty)
1074 "The target property of the Binding element created at %s:%d was changed from "
1075 "elsewhere. This does not overwrite the binding. The target property will still be "
1076 "updated when the value of the Binding element changes.",
1082#include "moc_qqmlbind_p.cpp"
const_iterator cbegin() const noexcept
const_iterator cend() const noexcept
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
QQmlAnyBinding is an abstraction over the various bindings in QML.
static QQmlAnyBinding createFromCodeString(const QQmlProperty &prop, const QString &code, QObject *obj, const QQmlRefPointer< QQmlContextData > &ctxt, const QString &url, quint16 lineNumber)
static void removeBindingFrom(QQmlProperty &prop)
static QQmlAnyBinding createTranslationBinding(const QQmlProperty &prop, const QQmlRefPointer< QV4::ExecutableCompilationUnit > &compilationUnit, const QV4::CompiledData::Binding *translationBinding, QObject *scopeObject=nullptr, QQmlRefPointer< QQmlContextData > context={})
static QQmlAnyBinding takeFrom(const QQmlProperty &prop)
Removes the binding from the property prop, and returns it as a QQmlAnyBinding if there was any.
void installOn(const QQmlProperty &target, InterceptorMode mode=IgnoreInterceptors)
~QQmlAnyBinding() noexcept
static QQmlAnyBinding ofProperty(const QQmlProperty &prop)
static QQmlAnyBinding createFromFunction(const QQmlProperty &prop, QV4::Function *function, QObject *obj, const QQmlRefPointer< QQmlContextData > &ctxt, QV4::ExecutionContext *scope)
void validate(QQmlBind *binding) const
std::unique_ptr< QQmlPropertyMap > delayedValues
QVarLengthArray< QQmlBindEntry, 1 > entries
QQmlBindEntry * targetEntry()
void decodeBinding(QQmlBind *q, const QString &propertyPrefix, QQmlData::DeferredData *deferredData, const QV4::CompiledData::Binding *binding, QQmlComponentPrivate::ConstructionState *immediateState)
void buildBindEntries(QQmlBind *q, QQmlComponentPrivate::DeferredState *deferredState)
void createDelayedValues()
void onDelayedValueChanged(const QString &delayedName)
void setRestoreMode(RestorationMode)
void classBegin() override
Invoked after class creation, but before any properties have been set.
RestorationMode restoreMode
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
void setTarget(const QQmlProperty &) override
Set the target property for the value source.
QQmlBind(QObject *parent=nullptr)
QObject * object()
\qmlproperty QtObject QtQml::Binding::target
void setValue(const QVariant &)
void setObject(QObject *)
void setProperty(const QString &)
void restoreModeChanged()
std::vector< ConstructionState > DeferredState
static void completeDeferred(QQmlEnginePrivate *enginePriv, DeferredState *deferredState)
static QQmlRefPointer< QQmlContextData > get(QQmlContext *context)
QQmlRefPointer< QQmlContextData > parent() const
The QQmlContext class defines a context within a QML engine.
static QQmlData * get(QObjectPrivate *priv, bool create)
QQmlContextData * outerContext
static QQmlEnginePrivate * get(QQmlEngine *e)
bool hasValidContext() const
void beginPopulateDeferred(const QQmlRefPointer< QQmlContextData > &context)
void populateDeferredBinding(const QQmlProperty &qmlProperty, int deferredIndex, const QV4::CompiledData::Binding *binding)
void finalizePopulateDeferred()
void valueChanged(const QString &key, const QVariant &value)
This signal is emitted whenever one of the values in the map is changed.
static QQmlProperty create(QObject *target, const QString &propertyName, const QQmlRefPointer< QQmlContextData > &context, QQmlPropertyPrivate::InitFlags flags)
static void removeBinding(const QQmlProperty &that)
static QQmlPropertyPrivate * get(const QQmlProperty &p)
The QQmlProperty class abstracts accessing properties on objects created from QML.
bool isValid() const
Returns true if the QQmlProperty refers to a valid property, otherwise false.
int index() const
Return the Qt metaobject index of the property.
QML_ANONYMOUSQObject * object
bool isWritable() const
Returns true if the property is writable, otherwise false.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool singleShot
whether the timer is a single-shot timer
QString toString(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
constexpr size_type size() const noexcept
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
~QVariant()
Destroys the QVariant and the contained object.
QSet< QString >::iterator it
Combined button and popup list for selecting options.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage return DBusPendingCall * pending
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define qCInfo(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLsizei const GLfloat * v
[13]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLdouble GLdouble GLdouble GLdouble q
QQmlContext * qmlContext(const QObject *obj)
static QQmlAnyBinding createBinding(const QQmlProperty &prop, const QV4::CompiledData::Binding *binding, const QQmlRefPointer< QV4::ExecutableCompilationUnit > &compilationUnit, const QQmlRefPointer< QQmlContextData > &contextData, QObject *scopeObject)
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
#define qPrintable(string)
#define QStringLiteral(str)
QUrl url("example.com")
[constructor-url-reference]
QQmlBindEntryKind previousKind
QQmlBindEntry(const QQmlBindEntry &other)
QQmlBindEntry & operator=(QQmlBindEntry &&other) noexcept
void setTarget(QQmlBind *q, const QQmlProperty &p)
QQmlBindEntryKind currentKind
QQmlBindEntry & operator=(const QQmlBindEntry &other)
QQmlBindEntryContent current
QQmlBindEntryContent previous
void validate(QQmlBind *q) const
QQmlBindEntry(QQmlBindEntry &&other) noexcept
QQmlObjectCreator * creator()
void setCompletePending(bool isPending)
void appendCreatorErrors()
QQmlObjectCreator * initCreator(QQmlRefPointer< QQmlContextData > parentContext, const QQmlRefPointer< QV4::ExecutableCompilationUnit > &compilationUnit, const QQmlRefPointer< QQmlContextData > &creationContext)
QQmlRefPointer< QQmlContextData > context
QQmlRefPointer< QV4::ExecutableCompilationUnit > compilationUnit
quint32_le propertyNameIndex
union QV4::CompiledData::Binding::@543 value
bool valueAsBoolean() const
quint32_le compiledScriptIndex
const Binding * bindingTable() const
ExecutionContext * rootContext() const
static Heap::QmlContext * create(QV4::ExecutionContext *parent, QQmlRefPointer< QQmlContextData > context, QObject *scopeObject)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent
QQmlBindEntryKind set(const QQmlBindEntryContent &other, QQmlBindEntryKind newKind, QQmlBindEntryKind oldKind)
QQmlBindEntryKind set(QQmlAnyBinding v, QQmlBindEntryKind oldKind)
QV4::PersistentValue v4Value
QQmlBindEntryKind set(QV4::PersistentValue v, QQmlBindEntryKind oldKind)
QQmlBindEntryKind set(QVariant v, QQmlBindEntryKind oldKind)
QQmlBindEntryKind set(QQmlBindEntryContent &&other, QQmlBindEntryKind newKind, QQmlBindEntryKind oldKind)
QQmlBindEntryKind destroy(QQmlBindEntryKind kind)