26class QQmlPropertyCacheVector
29 QQmlPropertyCacheVector() =
default;
30 QQmlPropertyCacheVector(QQmlPropertyCacheVector &&) =
default;
31 QQmlPropertyCacheVector &operator=(QQmlPropertyCacheVector &&) =
default;
33 ~QQmlPropertyCacheVector() { clear(); }
36 Q_ASSERT(size >= data.size());
37 return data.resize(size);
42 return int(data.size());
45 bool isEmpty()
const {
return data.isEmpty(); }
49 for (
int i = 0; i < data.size(); ++i)
54 void resetAndResize(
int size)
56 for (
int i = 0; i < data.size(); ++i) {
58 data[i] = BiPointer();
63 void append(
const QQmlPropertyCache::ConstPtr &cache) {
65 data.append(BiPointer(cache.data()));
66 Q_ASSERT(data.last().isT1());
67 Q_ASSERT(data.size() <= std::numeric_limits<
int>::max());
70 void appendOwn(
const QQmlPropertyCache::Ptr &cache) {
72 data.append(BiPointer(cache.data()));
73 Q_ASSERT(data.last().isT2());
74 Q_ASSERT(data.size() <= std::numeric_limits<
int>::max());
77 QQmlPropertyCache::ConstPtr at(
int index)
const
79 const auto entry = data.at(index);
85 QQmlPropertyCache::Ptr ownAt(
int index)
const
87 const auto entry = data.at(index);
90 return QQmlPropertyCache::Ptr();
93 void set(
int index,
const QQmlPropertyCache::ConstPtr &replacement) {
94 if (QQmlPropertyCache::ConstPtr oldCache = at(index)) {
96 if (replacement.data() == oldCache.data())
100 data[index] = replacement.data();
102 replacement->addref();
103 Q_ASSERT(data[index].isT1());
106 void setOwn(
int index,
const QQmlPropertyCache::Ptr &replacement) {
107 if (QQmlPropertyCache::ConstPtr oldCache = at(index)) {
108 if (replacement.data() != oldCache.data()) {
110 replacement->addref();
113 replacement->addref();
115 data[index] = replacement.data();
116 Q_ASSERT(data[index].isT2());
119 void setNeedsVMEMetaObject(
int index) { data[index].setFlag(); }
120 bool needsVMEMetaObject(
int index)
const {
return data.at(index).flag(); }
124 for (
auto &entry: data) {
126 entry =
static_cast<
const QQmlPropertyCache *>(entry.asT2());
127 Q_ASSERT(entry.isT1());
132 void releaseElement(
int i)
134 const auto &cache = data.at(i);
136 if (QQmlPropertyCache *data = cache.asT2())
138 }
else if (
const QQmlPropertyCache *data = cache.asT1()) {
143 Q_DISABLE_COPY(QQmlPropertyCacheVector)
144 using BiPointer = QBiPointer<
const QQmlPropertyCache, QQmlPropertyCache>;
145 QList<BiPointer> data;