25class QQmlPropertyCacheVector
28 QQmlPropertyCacheVector() =
default;
29 QQmlPropertyCacheVector(QQmlPropertyCacheVector &&) =
default;
30 QQmlPropertyCacheVector &operator=(QQmlPropertyCacheVector &&) =
default;
32 ~QQmlPropertyCacheVector() { clear(); }
35 Q_ASSERT(size >= data.size());
36 return data.resize(size);
41 return int(data.size());
44 bool isEmpty()
const {
return data.isEmpty(); }
48 for (
int i = 0; i < data.size(); ++i)
53 void resetAndResize(
int size)
55 for (
int i = 0; i < data.size(); ++i) {
57 data[i] = BiPointer();
62 void append(
const QQmlPropertyCache::ConstPtr &cache) {
64 data.append(BiPointer(cache.data()));
65 Q_ASSERT(data.last().isT1());
66 Q_ASSERT(data.size() <= std::numeric_limits<
int>::max());
69 void appendOwn(
const QQmlPropertyCache::Ptr &cache) {
71 data.append(BiPointer(cache.data()));
72 Q_ASSERT(data.last().isT2());
73 Q_ASSERT(data.size() <= std::numeric_limits<
int>::max());
76 QQmlPropertyCache::ConstPtr at(
int index)
const
78 const auto entry = data.at(index);
84 QQmlPropertyCache::Ptr ownAt(
int index)
const
86 const auto entry = data.at(index);
89 return QQmlPropertyCache::Ptr();
92 void set(
int index,
const QQmlPropertyCache::ConstPtr &replacement) {
93 if (QQmlPropertyCache::ConstPtr oldCache = at(index)) {
95 if (replacement.data() == oldCache.data())
99 data[index] = replacement.data();
100 replacement->addref();
101 Q_ASSERT(data[index].isT1());
104 void setOwn(
int index,
const QQmlPropertyCache::Ptr &replacement) {
105 if (QQmlPropertyCache::ConstPtr oldCache = at(index)) {
106 if (replacement.data() != oldCache.data()) {
108 replacement->addref();
111 replacement->addref();
113 data[index] = replacement.data();
114 Q_ASSERT(data[index].isT2());
117 void setNeedsVMEMetaObject(
int index) { data[index].setFlag(); }
118 bool needsVMEMetaObject(
int index)
const {
return data.at(index).flag(); }
122 for (
auto &entry: data) {
124 entry =
static_cast<
const QQmlPropertyCache *>(entry.asT2());
125 Q_ASSERT(entry.isT1());
130 void releaseElement(
int i)
132 const auto &cache = data.at(i);
134 if (QQmlPropertyCache *data = cache.asT2())
136 }
else if (
const QQmlPropertyCache *data = cache.asT1()) {
141 Q_DISABLE_COPY(QQmlPropertyCacheVector)
142 using BiPointer = QBiPointer<
const QQmlPropertyCache, QQmlPropertyCache>;
143 QVector<BiPointer> data;