aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmldata_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/qml/qqmldata_p.h')
-rw-r--r--src/qml/qml/qqmldata_p.h58
1 files changed, 36 insertions, 22 deletions
diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h
index d692feb975..20b96d2c4b 100644
--- a/src/qml/qml/qqmldata_p.h
+++ b/src/qml/qml/qqmldata_p.h
@@ -56,6 +56,7 @@
#include <private/qqmlpropertyindex_p.h>
#include <private/qv4value_p.h>
#include <private/qv4persistent_p.h>
+#include <private/qqmlrefcount_p.h>
#include <qjsengine.h>
#include <qvector.h>
@@ -76,6 +77,7 @@ class QQmlNotifierEndpoint;
namespace QV4 {
namespace CompiledData {
struct CompilationUnit;
+struct Binding;
}
}
@@ -115,6 +117,7 @@ class Q_QML_PRIVATE_EXPORT QQmlData : public QAbstractDeclarativeData
{
public:
QQmlData();
+ ~QQmlData();
static inline void init() {
static bool initialized = false;
@@ -155,18 +158,21 @@ public:
quint32 hasInterceptorMetaObject:1;
quint32 hasVMEMetaObject:1;
quint32 parentFrozen:1;
- quint32 dummy:22;
+ quint32 dummy:6;
// When bindingBitsSize < sizeof(ptr), we store the binding bit flags inside
// bindingBitsValue. When we need more than sizeof(ptr) bits, we allocated
// sufficient space and use bindingBits to point to it.
- int bindingBitsSize;
+ quint32 bindingBitsArraySize : 16;
typedef quintptr BindingBitsType;
+ enum {
+ BitsPerType = sizeof(BindingBitsType) * 8,
+ InlineBindingArraySize = 2
+ };
union {
BindingBitsType *bindingBits;
- BindingBitsType bindingBitsValue;
+ BindingBitsType bindingBitsValue[InlineBindingArraySize];
};
- enum { MaxInlineBits = sizeof(BindingBitsType) * 8 };
struct NotifyList {
quint64 connectionMask;
@@ -189,9 +195,9 @@ public:
void disconnectNotifiers();
// The context that created the C++ object
- QQmlContextData *context = 0;
+ QQmlContextData *context = nullptr;
// The outermost context in which this object lives
- QQmlContextData *outerContext = 0;
+ QQmlContextData *outerContext = nullptr;
QQmlContextDataRef ownContext;
QQmlAbstractBinding *bindings;
@@ -215,13 +221,18 @@ public:
quint32 jsEngineId; // id of the engine that created the jsWrapper
struct DeferredData {
+ DeferredData();
+ ~DeferredData();
unsigned int deferredIdx;
- QV4::CompiledData::CompilationUnit *compilationUnit;//Not always the same as the other compilation unit
+ QMultiHash<int, const QV4::CompiledData::Binding *> bindings;
+ QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit;//Not always the same as the other compilation unit
QQmlContextData *context;//Could be either context or outerContext
+ Q_DISABLE_COPY(DeferredData);
};
- QV4::CompiledData::CompilationUnit *compilationUnit;
+ QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit;
QVector<DeferredData *> deferredData;
+ void deferData(int objectIndex, QV4::CompiledData::CompilationUnit *, QQmlContextData *);
void releaseDeferredData();
QV4::WeakValue jsWrapper;
@@ -236,13 +247,13 @@ public:
// to be avoided because QObjectPrivate::currentChildBeingDeleted is in use.
if (priv->isDeletingChildren || priv->wasDeleted) {
Q_ASSERT(!create);
- return 0;
+ return nullptr;
} else if (priv->declarativeData) {
return static_cast<QQmlData *>(priv->declarativeData);
} else if (create) {
return createQQmlData(priv);
} else {
- return 0;
+ return nullptr;
}
}
@@ -253,10 +264,10 @@ public:
return false;
}
- bool hasExtendedData() const { return extendedData != 0; }
+ bool hasExtendedData() const { return extendedData != nullptr; }
QHash<int, QObject *> *attachedProperties() const;
- static inline bool wasDeleted(QObject *);
+ static inline bool wasDeleted(const QObject *);
static void markAsDeleted(QObject *);
static void setQueuedForDeletion(QObject *);
@@ -272,6 +283,9 @@ public:
return createPropertyCache(engine, object);
}
+ Q_ALWAYS_INLINE static uint offsetForBit(int bit) { return static_cast<uint>(bit) / BitsPerType; }
+ Q_ALWAYS_INLINE static BindingBitsType bitFlagForBit(int bit) { return BindingBitsType(1) << (static_cast<uint>(bit) & (BitsPerType - 1)); }
+
private:
// For attachedProperties
mutable QQmlDataExtended *extendedData;
@@ -283,26 +297,26 @@ private:
Q_ALWAYS_INLINE bool hasBitSet(int bit) const
{
- if (bindingBitsSize <= bit)
+ uint offset = offsetForBit(bit);
+ if (bindingBitsArraySize <= offset)
return false;
- if (bindingBitsSize == MaxInlineBits)
- return bindingBitsValue & (BindingBitsType(1) << bit);
- else
- return bindingBits[bit / MaxInlineBits] & (BindingBitsType(1) << (bit % MaxInlineBits));
+ const BindingBitsType *bits = (bindingBitsArraySize == InlineBindingArraySize) ? bindingBitsValue : bindingBits;
+ return bits[offset] & bitFlagForBit(bit);
}
+ Q_DISABLE_COPY(QQmlData);
};
-bool QQmlData::wasDeleted(QObject *object)
+bool QQmlData::wasDeleted(const QObject *object)
{
if (!object)
return true;
- QObjectPrivate *priv = QObjectPrivate::get(object);
+ const QObjectPrivate *priv = QObjectPrivate::get(object);
if (!priv || priv->wasDeleted)
return true;
- QQmlData *ddata = QQmlData::get(object);
+ const QQmlData *ddata = QQmlData::get(object);
return ddata && ddata->isQueuedForDeletion;
}
@@ -311,7 +325,7 @@ QQmlNotifierEndpoint *QQmlData::notify(int index)
Q_ASSERT(index <= 0xFFFF);
if (!notifyList || !(notifyList->connectionMask & (1ULL << quint64(index % 64)))) {
- return 0;
+ return nullptr;
} else if (index < notifyList->notifiesSize) {
return notifyList->notifies[index];
} else if (index <= notifyList->maximumTodoIndex) {
@@ -321,7 +335,7 @@ QQmlNotifierEndpoint *QQmlData::notify(int index)
if (index < notifyList->notifiesSize) {
return notifyList->notifies[index];
} else {
- return 0;
+ return nullptr;
}
}