Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/designer/qqmldesignermetaobject.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | static QHash<QDynamicMetaObjectData *, bool> nodeInstanceMetaObjectList; | - | ||||||||||||
7 | static void (*notifyPropertyChangeCallBack)(QObject*, const QQuickDesignerSupport::PropertyName &propertyName) = nullptr; | - | ||||||||||||
8 | - | |||||||||||||
9 | struct MetaPropertyData { | - | ||||||||||||
10 | inline QPair<QVariant, bool> &getDataRef(int idx) { | - | ||||||||||||
11 | while (m_data.count() <= idx
| 8-88 | ||||||||||||
12 | m_data << QPair<QVariant, bool>(QVariant(), false); executed 88 times by 1 test: m_data << QPair<QVariant, bool>(QVariant(), false); Executed by:
| 88 | ||||||||||||
13 | return executed 8 times by 1 test: m_data[idx];return m_data[idx]; Executed by:
executed 8 times by 1 test: return m_data[idx]; Executed by:
| 8 | ||||||||||||
14 | } | - | ||||||||||||
15 | - | |||||||||||||
16 | inline QVariant &getData(int idx) { | - | ||||||||||||
17 | QPair<QVariant, bool> &prop = getDataRef(idx); | - | ||||||||||||
18 | if (!prop.second
| 0-4 | ||||||||||||
19 | prop.first = QVariant(); | - | ||||||||||||
20 | prop.second = true; | - | ||||||||||||
21 | } never executed: end of block | 0 | ||||||||||||
22 | return executed 4 times by 1 test: prop.first;return prop.first; Executed by:
executed 4 times by 1 test: return prop.first; Executed by:
| 4 | ||||||||||||
23 | } | - | ||||||||||||
24 | - | |||||||||||||
25 | inline bool hasData(int idx) const { | - | ||||||||||||
26 | if (idx >= m_data.count()
| 0 | ||||||||||||
27 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
28 | return never executed: m_data[idx].second;return m_data[idx].second; never executed: return m_data[idx].second; | 0 | ||||||||||||
29 | } | - | ||||||||||||
30 | - | |||||||||||||
31 | inline int count() { return executed 2 times by 1 test: m_data.count();return m_data.count(); Executed by:
executed 2 times by 1 test: }return m_data.count(); Executed by:
| 2 | ||||||||||||
32 | - | |||||||||||||
33 | QVector<QPair<QVariant, bool> > m_data; | - | ||||||||||||
34 | }; | - | ||||||||||||
35 | - | |||||||||||||
36 | static QQmlPropertyCache *cacheForObject(QObject *object, QQmlEngine *engine) | - | ||||||||||||
37 | { | - | ||||||||||||
38 | QQmlVMEMetaObject *metaObject = QQmlVMEMetaObject::get(object); | - | ||||||||||||
39 | if (metaObject
| 2 | ||||||||||||
40 | return executed 2 times by 1 test: metaObject->cache.data();return metaObject->cache.data(); Executed by:
executed 2 times by 1 test: return metaObject->cache.data(); Executed by:
| 2 | ||||||||||||
41 | - | |||||||||||||
42 | return executed 2 times by 1 test: QQmlEnginePrivate::get(engine)->cache(object);return QQmlEnginePrivate::get(engine)->cache(object); Executed by:
executed 2 times by 1 test: return QQmlEnginePrivate::get(engine)->cache(object); Executed by:
| 2 | ||||||||||||
43 | } | - | ||||||||||||
44 | - | |||||||||||||
45 | QQmlDesignerMetaObject* QQmlDesignerMetaObject::getNodeInstanceMetaObject(QObject *object, QQmlEngine *engine) | - | ||||||||||||
46 | { | - | ||||||||||||
47 | - | |||||||||||||
48 | QObjectPrivate *op = QObjectPrivate::get(object); | - | ||||||||||||
49 | QDynamicMetaObjectData *parent = op->metaObject; | - | ||||||||||||
50 | if (nodeInstanceMetaObjectList.contains(parent)
| 2-4 | ||||||||||||
51 | return executed 2 times by 1 test: static_cast<QQmlDesignerMetaObject *>(parent);return static_cast<QQmlDesignerMetaObject *>(parent); Executed by:
executed 2 times by 1 test: return static_cast<QQmlDesignerMetaObject *>(parent); Executed by:
| 2 | ||||||||||||
52 | - | |||||||||||||
53 | - | |||||||||||||
54 | - | |||||||||||||
55 | QQmlData *ddata = QQmlData::get(object, false); | - | ||||||||||||
56 | - | |||||||||||||
57 | const bool hadVMEMetaObject = ddata
| 0-4 | ||||||||||||
58 | QQmlDesignerMetaObject *mo = new QQmlDesignerMetaObject(object, engine); | - | ||||||||||||
59 | - | |||||||||||||
60 | if (ddata
| 0-4 | ||||||||||||
61 | ddata->hasVMEMetaObject = hadVMEMetaObject; executed 4 times by 1 test: ddata->hasVMEMetaObject = hadVMEMetaObject; Executed by:
| 4 | ||||||||||||
62 | return executed 4 times by 1 test: mo;return mo; Executed by:
executed 4 times by 1 test: return mo; Executed by:
| 4 | ||||||||||||
63 | } | - | ||||||||||||
64 | - | |||||||||||||
65 | void QQmlDesignerMetaObject::init(QObject *object, QQmlEngine *engine) | - | ||||||||||||
66 | { | - | ||||||||||||
67 | - | |||||||||||||
68 | m_type = new QQmlOpenMetaObjectType(metaObjectParent(), engine); | - | ||||||||||||
69 | m_type->addref(); | - | ||||||||||||
70 | - | |||||||||||||
71 | copyTypeMetaObject(); | - | ||||||||||||
72 | - | |||||||||||||
73 | - | |||||||||||||
74 | QObjectPrivate *op = QObjectPrivate::get(object); | - | ||||||||||||
75 | op->metaObject = this; | - | ||||||||||||
76 | - | |||||||||||||
77 | cache = QQmlEnginePrivate::get(engine)->cache(this); | - | ||||||||||||
78 | - | |||||||||||||
79 | nodeInstanceMetaObjectList.insert(this, true); | - | ||||||||||||
80 | hasAssignedMetaObjectData = true; | - | ||||||||||||
81 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||
82 | - | |||||||||||||
83 | QQmlDesignerMetaObject::QQmlDesignerMetaObject(QObject *object, QQmlEngine *engine) | - | ||||||||||||
84 | : QQmlVMEMetaObject(engine->handle(), object, cacheForObject(object, engine), nullptr, -1), | - | ||||||||||||
85 | m_context(engine->contextForObject(object)), | - | ||||||||||||
86 | m_data(new MetaPropertyData) | - | ||||||||||||
87 | { | - | ||||||||||||
88 | init(object, engine); | - | ||||||||||||
89 | - | |||||||||||||
90 | QQmlData *ddata = QQmlData::get(object, false); | - | ||||||||||||
91 | - | |||||||||||||
92 | if (ddata
| 0-4 | ||||||||||||
93 | cache->setParent(ddata->propertyCache); | - | ||||||||||||
94 | cache->invalidate(engine, this); | - | ||||||||||||
95 | ddata->propertyCache->release(); | - | ||||||||||||
96 | ddata->propertyCache = cache.data(); | - | ||||||||||||
97 | ddata->propertyCache->addref(); | - | ||||||||||||
98 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||
99 | - | |||||||||||||
100 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||
101 | - | |||||||||||||
102 | QQmlDesignerMetaObject::~QQmlDesignerMetaObject() | - | ||||||||||||
103 | { | - | ||||||||||||
104 | m_type->release(); | - | ||||||||||||
105 | - | |||||||||||||
106 | nodeInstanceMetaObjectList.remove(this); | - | ||||||||||||
107 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||
108 | - | |||||||||||||
109 | void QQmlDesignerMetaObject::createNewDynamicProperty(const QString &name) | - | ||||||||||||
110 | { | - | ||||||||||||
111 | int id = m_type->createProperty(name.toUtf8()); | - | ||||||||||||
112 | copyTypeMetaObject(); | - | ||||||||||||
113 | setValue(id, QVariant()); | - | ||||||||||||
114 | ((id >= 0) ? static_cast<void>(0) : qt_assert("id >= 0", __FILE__, 160)); | - | ||||||||||||
115 | (void)id;; | - | ||||||||||||
116 | - | |||||||||||||
117 | - | |||||||||||||
118 | QQmlPropertyCache *oldParent = cache->parent(); | - | ||||||||||||
119 | QQmlEnginePrivate::get(m_context->engine())->cache(this)->invalidate(m_context->engine(), this); | - | ||||||||||||
120 | cache->setParent(oldParent); | - | ||||||||||||
121 | - | |||||||||||||
122 | QQmlProperty property(myObject(), name, m_context); | - | ||||||||||||
123 | ((property.isValid()) ? static_cast<void>(0) : qt_assert("property.isValid()", __FILE__, 169)); | - | ||||||||||||
124 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
125 | - | |||||||||||||
126 | void QQmlDesignerMetaObject::setValue(int id, const QVariant &value) | - | ||||||||||||
127 | { | - | ||||||||||||
128 | QPair<QVariant, bool> &prop = m_data->getDataRef(id); | - | ||||||||||||
129 | prop.first = propertyWriteValue(id, value); | - | ||||||||||||
130 | prop.second = true; | - | ||||||||||||
131 | QMetaObject::activate(myObject(), id + m_type->signalOffset(), nullptr); | - | ||||||||||||
132 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
133 | - | |||||||||||||
134 | QVariant QQmlDesignerMetaObject::propertyWriteValue(int, const QVariant &value) | - | ||||||||||||
135 | { | - | ||||||||||||
136 | return executed 4 times by 1 test: value;return value; Executed by:
executed 4 times by 1 test: return value; Executed by:
| 4 | ||||||||||||
137 | } | - | ||||||||||||
138 | - | |||||||||||||
139 | const QAbstractDynamicMetaObject *QQmlDesignerMetaObject::dynamicMetaObjectParent() const | - | ||||||||||||
140 | { | - | ||||||||||||
141 | if (QQmlVMEMetaObject::parent.isT1()
| 12-14 | ||||||||||||
142 | return executed 14 times by 1 test: QQmlVMEMetaObject::parent.asT1()->toDynamicMetaObject(QQmlVMEMetaObject::object);return QQmlVMEMetaObject::parent.asT1()->toDynamicMetaObject(QQmlVMEMetaObject::object); Executed by:
executed 14 times by 1 test: return QQmlVMEMetaObject::parent.asT1()->toDynamicMetaObject(QQmlVMEMetaObject::object); Executed by:
| 14 | ||||||||||||
143 | else | - | ||||||||||||
144 | return executed 12 times by 1 test: nullptr;return nullptr; Executed by:
executed 12 times by 1 test: return nullptr; Executed by:
| 12 | ||||||||||||
145 | } | - | ||||||||||||
146 | - | |||||||||||||
147 | const QMetaObject *QQmlDesignerMetaObject::metaObjectParent() const | - | ||||||||||||
148 | { | - | ||||||||||||
149 | if (QQmlVMEMetaObject::parent.isT1()
| 2 | ||||||||||||
150 | return executed 2 times by 1 test: QQmlVMEMetaObject::parent.asT1()->toDynamicMetaObject(QQmlVMEMetaObject::object);return QQmlVMEMetaObject::parent.asT1()->toDynamicMetaObject(QQmlVMEMetaObject::object); Executed by:
executed 2 times by 1 test: return QQmlVMEMetaObject::parent.asT1()->toDynamicMetaObject(QQmlVMEMetaObject::object); Executed by:
| 2 | ||||||||||||
151 | - | |||||||||||||
152 | return executed 2 times by 1 test: QQmlVMEMetaObject::parent.asT2();return QQmlVMEMetaObject::parent.asT2(); Executed by:
executed 2 times by 1 test: return QQmlVMEMetaObject::parent.asT2(); Executed by:
| 2 | ||||||||||||
153 | } | - | ||||||||||||
154 | - | |||||||||||||
155 | int QQmlDesignerMetaObject::propertyOffset() const | - | ||||||||||||
156 | { | - | ||||||||||||
157 | return executed 2 times by 1 test: cache->propertyOffset();return cache->propertyOffset(); Executed by:
executed 2 times by 1 test: return cache->propertyOffset(); Executed by:
| 2 | ||||||||||||
158 | } | - | ||||||||||||
159 | - | |||||||||||||
160 | int QQmlDesignerMetaObject::openMetaCall(QObject *o, QMetaObject::Call call, int id, void **a) | - | ||||||||||||
161 | { | - | ||||||||||||
162 | if ((call == QMetaObject::ReadProperty
| 0-10 | ||||||||||||
163 | && id >= m_type->propertyOffset()
| 6-10 | ||||||||||||
164 | int propId = id - m_type->propertyOffset(); | - | ||||||||||||
165 | if (call == QMetaObject::ReadProperty
| 2-4 | ||||||||||||
166 | - | |||||||||||||
167 | *reinterpret_cast<QVariant *>(a[0]) = m_data->getData(propId); | - | ||||||||||||
168 | } executed 4 times by 1 test: else if (call == QMetaObject::WritePropertyend of block Executed by:
| 0-4 | ||||||||||||
169 | if (propId <= m_data->count()
| 0-2 | ||||||||||||
170 | - | |||||||||||||
171 | QPair<QVariant, bool> &prop = m_data->getDataRef(propId); | - | ||||||||||||
172 | prop.first = propertyWriteValue(propId, *reinterpret_cast<QVariant *>(a[0])); | - | ||||||||||||
173 | prop.second = true; | - | ||||||||||||
174 | - | |||||||||||||
175 | activate(myObject(), m_type->signalOffset() + propId, nullptr); | - | ||||||||||||
176 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
177 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
178 | return executed 6 times by 1 test: -1;return -1; Executed by:
executed 6 times by 1 test: return -1; Executed by:
| 6 | ||||||||||||
179 | } else { | - | ||||||||||||
180 | QAbstractDynamicMetaObject *directParent = parent(); | - | ||||||||||||
181 | if (directParent
| 4-6 | ||||||||||||
182 | return executed 4 times by 1 test: directParent->metaCall(o, call, id, a);return directParent->metaCall(o, call, id, a); Executed by:
executed 4 times by 1 test: return directParent->metaCall(o, call, id, a); Executed by:
| 4 | ||||||||||||
183 | else | - | ||||||||||||
184 | return executed 6 times by 1 test: myObject()->qt_metacall(call, id, a);return myObject()->qt_metacall(call, id, a); Executed by:
executed 6 times by 1 test: return myObject()->qt_metacall(call, id, a); Executed by:
| 6 | ||||||||||||
185 | } | - | ||||||||||||
186 | } | - | ||||||||||||
187 | - | |||||||||||||
188 | int QQmlDesignerMetaObject::metaCall(QObject *o, QMetaObject::Call call, int id, void **a) | - | ||||||||||||
189 | { | - | ||||||||||||
190 | ((myObject() == o) ? static_cast<void>(0) : qt_assert("myObject() == o", __FILE__, 236)); | - | ||||||||||||
191 | - | |||||||||||||
192 | int metaCallReturnValue = -1; | - | ||||||||||||
193 | - | |||||||||||||
194 | const QMetaProperty propertyById = QQmlVMEMetaObject::property(id); | - | ||||||||||||
195 | - | |||||||||||||
196 | if (call == QMetaObject::WriteProperty
| 6-10 | ||||||||||||
197 | && propertyById.userType() == QMetaType::QVariant
| 2-4 | ||||||||||||
198 | && reinterpret_cast<
| 0-2 | ||||||||||||
199 | && qt_is_nan(reinterpret_cast<QVariant *>(a[0])->toDouble())
| 0 | ||||||||||||
200 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
201 | } | - | ||||||||||||
202 | - | |||||||||||||
203 | if (call == QMetaObject::WriteProperty
| 6-10 | ||||||||||||
204 | && propertyById.userType() == QMetaType::Double
| 0-6 | ||||||||||||
205 | && qt_is_nan(*reinterpret_cast<double*>(a[0]))
| 0 | ||||||||||||
206 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
207 | } | - | ||||||||||||
208 | - | |||||||||||||
209 | if (call == QMetaObject::WriteProperty
| 6-10 | ||||||||||||
210 | && propertyById.userType() == QMetaType::Float
| 0-6 | ||||||||||||
211 | && qt_is_nan(*reinterpret_cast<float*>(a[0]))
| 0 | ||||||||||||
212 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
213 | } | - | ||||||||||||
214 | - | |||||||||||||
215 | QVariant oldValue; | - | ||||||||||||
216 | - | |||||||||||||
217 | if (call == QMetaObject::WriteProperty
| 2-10 | ||||||||||||
218 | { | - | ||||||||||||
219 | oldValue = propertyById.read(myObject()); | - | ||||||||||||
220 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
221 | - | |||||||||||||
222 | QAbstractDynamicMetaObject *directParent = parent(); | - | ||||||||||||
223 | if (directParent
| 0-10 | ||||||||||||
224 | metaCallReturnValue = directParent->metaCall(o, call, id, a); | - | ||||||||||||
225 | } never executed: else {end of block | 0 | ||||||||||||
226 | openMetaCall(o, call, id, a); | - | ||||||||||||
227 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||
228 | - | |||||||||||||
229 | - | |||||||||||||
230 | if (call == QMetaObject::WriteProperty
| 6-10 | ||||||||||||
231 | && !propertyById.hasNotifySignal()
| 2-4 | ||||||||||||
232 | && oldValue != propertyById.read(myObject())
| 0-2 | ||||||||||||
233 | notifyPropertyChange(id); executed 2 times by 1 test: notifyPropertyChange(id); Executed by:
| 2 | ||||||||||||
234 | - | |||||||||||||
235 | return executed 16 times by 1 test: metaCallReturnValue;return metaCallReturnValue; Executed by:
executed 16 times by 1 test: return metaCallReturnValue; Executed by:
| 16 | ||||||||||||
236 | } | - | ||||||||||||
237 | - | |||||||||||||
238 | void QQmlDesignerMetaObject::notifyPropertyChange(int id) | - | ||||||||||||
239 | { | - | ||||||||||||
240 | const QMetaProperty propertyById = property(id); | - | ||||||||||||
241 | - | |||||||||||||
242 | if (id < propertyOffset()
| 0-2 | ||||||||||||
243 | if (notifyPropertyChangeCallBack
| 0-2 | ||||||||||||
244 | notifyPropertyChangeCallBack(myObject(), propertyById.name()); executed 2 times by 1 test: notifyPropertyChangeCallBack(myObject(), propertyById.name()); Executed by:
| 2 | ||||||||||||
245 | } executed 2 times by 1 test: else {end of block Executed by:
| 2 | ||||||||||||
246 | if (notifyPropertyChangeCallBack
| 0 | ||||||||||||
247 | notifyPropertyChangeCallBack(myObject(), name(id - propertyOffset())); never executed: notifyPropertyChangeCallBack(myObject(), name(id - propertyOffset())); | 0 | ||||||||||||
248 | } never executed: end of block | 0 | ||||||||||||
249 | } | - | ||||||||||||
250 | - | |||||||||||||
251 | int QQmlDesignerMetaObject::count() const | - | ||||||||||||
252 | { | - | ||||||||||||
253 | return never executed: m_type->propertyCount();return m_type->propertyCount(); never executed: return m_type->propertyCount(); | 0 | ||||||||||||
254 | } | - | ||||||||||||
255 | - | |||||||||||||
256 | QByteArray QQmlDesignerMetaObject::name(int idx) const | - | ||||||||||||
257 | { | - | ||||||||||||
258 | return never executed: m_type->propertyName(idx);return m_type->propertyName(idx); never executed: return m_type->propertyName(idx); | 0 | ||||||||||||
259 | } | - | ||||||||||||
260 | - | |||||||||||||
261 | void QQmlDesignerMetaObject::copyTypeMetaObject() | - | ||||||||||||
262 | { | - | ||||||||||||
263 | *static_cast<QMetaObject *>(this) = *m_type->metaObject(); | - | ||||||||||||
264 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||
265 | - | |||||||||||||
266 | void QQmlDesignerMetaObject::registerNotifyPropertyChangeCallBack(void (*callback)(QObject *, const QQuickDesignerSupport::PropertyName &)) | - | ||||||||||||
267 | { | - | ||||||||||||
268 | notifyPropertyChangeCallBack = callback; | - | ||||||||||||
269 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
270 | - | |||||||||||||
271 | - | |||||||||||||
Switch to Source code | Preprocessed file |