Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/qml/qqmlcontext_p.h |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | - | |||||||||||||
8 | - | |||||||||||||
9 | - | |||||||||||||
10 | class QQmlContext; | - | ||||||||||||
11 | class QQmlExpression; | - | ||||||||||||
12 | class QQmlEngine; | - | ||||||||||||
13 | class QQmlExpression; | - | ||||||||||||
14 | class QQmlExpressionPrivate; | - | ||||||||||||
15 | class QQmlJavaScriptExpression; | - | ||||||||||||
16 | class QQmlContextData; | - | ||||||||||||
17 | class QQmlGuardedContextData; | - | ||||||||||||
18 | class QQmlIncubatorPrivate; | - | ||||||||||||
19 | - | |||||||||||||
20 | class QQmlContextPrivate : public QObjectPrivate | - | ||||||||||||
21 | { | - | ||||||||||||
22 | inline QQmlContext* q_func() { return static_cast<QQmlContext *>(q_ptr); } inline const QQmlContext* q_func() const { return static_cast<const QQmlContext *>(q_ptr); } friend class QQmlContext; | - | ||||||||||||
23 | public: | - | ||||||||||||
24 | QQmlContextPrivate(); | - | ||||||||||||
25 | - | |||||||||||||
26 | QQmlContextData *data; | - | ||||||||||||
27 | - | |||||||||||||
28 | QList<QVariant> propertyValues; | - | ||||||||||||
29 | int notifyIndex; | - | ||||||||||||
30 | - | |||||||||||||
31 | static QQmlContextPrivate *get(QQmlContext *context) { | - | ||||||||||||
32 | return executed 1813765 times by 140 tests: static_cast<QQmlContextPrivate *>(QObjectPrivate::get(context));return static_cast<QQmlContextPrivate *>(QObjectPrivate::get(context)); Executed by:
executed 1813765 times by 140 tests: return static_cast<QQmlContextPrivate *>(QObjectPrivate::get(context)); Executed by:
| 1813765 | ||||||||||||
33 | } | - | ||||||||||||
34 | static QQmlContext *get(QQmlContextPrivate *context) { | - | ||||||||||||
35 | return never executed: static_cast<QQmlContext *>(context->q_func());return static_cast<QQmlContext *>(context->q_func()); never executed: return static_cast<QQmlContext *>(context->q_func()); | 0 | ||||||||||||
36 | } | - | ||||||||||||
37 | - | |||||||||||||
38 | - | |||||||||||||
39 | QList<QPointer<QObject> > instances; | - | ||||||||||||
40 | - | |||||||||||||
41 | static int context_count(QQmlListProperty<QObject> *); | - | ||||||||||||
42 | static QObject *context_at(QQmlListProperty<QObject> *, int); | - | ||||||||||||
43 | }; | - | ||||||||||||
44 | - | |||||||||||||
45 | class QQmlComponentAttached; | - | ||||||||||||
46 | - | |||||||||||||
47 | class __attribute__((visibility("default"))) QQmlContextData | - | ||||||||||||
48 | { | - | ||||||||||||
49 | public: | - | ||||||||||||
50 | QQmlContextData(); | - | ||||||||||||
51 | QQmlContextData(QQmlContext *); | - | ||||||||||||
52 | void emitDestruction(); | - | ||||||||||||
53 | void clearContext(); | - | ||||||||||||
54 | void clearContextRecursively(); | - | ||||||||||||
55 | void invalidate(); | - | ||||||||||||
56 | - | |||||||||||||
57 | inline bool isValid() const { | - | ||||||||||||
58 | return executed 2423316 times by 140 tests: engine && (!isInternal || !contextObject || !QObjectPrivate::get(contextObject)->wasDeleted);return engine && (!isInternal || !contextObject || !QObjectPrivate::get(contextObject)->wasDeleted); Executed by:
executed 2423316 times by 140 tests: return engine && (!isInternal || !contextObject || !QObjectPrivate::get(contextObject)->wasDeleted); Executed by:
| 2423316 | ||||||||||||
59 | } | - | ||||||||||||
60 | - | |||||||||||||
61 | - | |||||||||||||
62 | QQmlContextData *parent = nullptr; | - | ||||||||||||
63 | QQmlEngine *engine; | - | ||||||||||||
64 | - | |||||||||||||
65 | void setParent(QQmlContextData *, bool stronglyReferencedByParent = false); | - | ||||||||||||
66 | void refreshExpressions(); | - | ||||||||||||
67 | - | |||||||||||||
68 | void addObject(QObject *); | - | ||||||||||||
69 | - | |||||||||||||
70 | QUrl resolvedUrl(const QUrl &); | - | ||||||||||||
71 | - | |||||||||||||
72 | - | |||||||||||||
73 | - | |||||||||||||
74 | QQmlContext *asQQmlContext(); | - | ||||||||||||
75 | QQmlContextPrivate *asQQmlContextPrivate(); | - | ||||||||||||
76 | quint32 refCount = 0; | - | ||||||||||||
77 | quint32 isInternal:1; | - | ||||||||||||
78 | quint32 isJSContext:1; | - | ||||||||||||
79 | quint32 isPragmaLibraryContext:1; | - | ||||||||||||
80 | quint32 unresolvedNames:1; | - | ||||||||||||
81 | quint32 hasEmittedDestruction:1; | - | ||||||||||||
82 | quint32 isRootObjectInCreation:1; | - | ||||||||||||
83 | quint32 stronglyReferencedByParent:1; | - | ||||||||||||
84 | quint32 dummy:25; | - | ||||||||||||
85 | QQmlContext *publicContext; | - | ||||||||||||
86 | - | |||||||||||||
87 | - | |||||||||||||
88 | QQmlIncubatorPrivate *incubator; | - | ||||||||||||
89 | - | |||||||||||||
90 | - | |||||||||||||
91 | QQmlRefPointer<QV4::CompiledData::CompilationUnit> typeCompilationUnit; | - | ||||||||||||
92 | - | |||||||||||||
93 | - | |||||||||||||
94 | int componentObjectIndex; | - | ||||||||||||
95 | - | |||||||||||||
96 | void initFromTypeCompilationUnit(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &unit, int subComponentIndex); | - | ||||||||||||
97 | - | |||||||||||||
98 | - | |||||||||||||
99 | mutable QV4::IdentifierHash propertyNameCache; | - | ||||||||||||
100 | const QV4::IdentifierHash &propertyNames() const; | - | ||||||||||||
101 | QV4::IdentifierHash &detachedPropertyNames(); | - | ||||||||||||
102 | - | |||||||||||||
103 | - | |||||||||||||
104 | QObject *contextObject; | - | ||||||||||||
105 | - | |||||||||||||
106 | - | |||||||||||||
107 | QV4::PersistentValue importedScripts; | - | ||||||||||||
108 | - | |||||||||||||
109 | QUrl baseUrl; | - | ||||||||||||
110 | QString baseUrlString; | - | ||||||||||||
111 | - | |||||||||||||
112 | QUrl url() const; | - | ||||||||||||
113 | QString urlString() const; | - | ||||||||||||
114 | - | |||||||||||||
115 | - | |||||||||||||
116 | QQmlRefPointer<QQmlTypeNameCache> imports; | - | ||||||||||||
117 | - | |||||||||||||
118 | - | |||||||||||||
119 | QQmlContextData *childContexts = nullptr; | - | ||||||||||||
120 | - | |||||||||||||
121 | - | |||||||||||||
122 | QQmlContextData *nextChild; | - | ||||||||||||
123 | QQmlContextData **prevChild; | - | ||||||||||||
124 | - | |||||||||||||
125 | - | |||||||||||||
126 | QQmlJavaScriptExpression *expressions; | - | ||||||||||||
127 | - | |||||||||||||
128 | - | |||||||||||||
129 | QQmlData *contextObjects; | - | ||||||||||||
130 | - | |||||||||||||
131 | - | |||||||||||||
132 | QQmlGuardedContextData *contextGuards = nullptr; | - | ||||||||||||
133 | - | |||||||||||||
134 | - | |||||||||||||
135 | struct ContextGuard : public QQmlGuard<QObject> | - | ||||||||||||
136 | { | - | ||||||||||||
137 | inline ContextGuard(); | - | ||||||||||||
138 | inline ContextGuard &operator=(QObject *obj); | - | ||||||||||||
139 | inline void objectDestroyed(QObject *) override; | - | ||||||||||||
140 | - | |||||||||||||
141 | inline bool wasSet() const; | - | ||||||||||||
142 | - | |||||||||||||
143 | QFlagPointer<QQmlContextData> context; | - | ||||||||||||
144 | QQmlNotifier bindings; | - | ||||||||||||
145 | }; | - | ||||||||||||
146 | ContextGuard *idValues; | - | ||||||||||||
147 | int idValueCount; | - | ||||||||||||
148 | void setIdProperty(int, QObject *); | - | ||||||||||||
149 | - | |||||||||||||
150 | - | |||||||||||||
151 | QQmlContextDataRef linkedContext; | - | ||||||||||||
152 | - | |||||||||||||
153 | - | |||||||||||||
154 | - | |||||||||||||
155 | QQmlComponentAttached *componentAttached; | - | ||||||||||||
156 | - | |||||||||||||
157 | - | |||||||||||||
158 | QString findObjectId(const QObject *obj) const; | - | ||||||||||||
159 | - | |||||||||||||
160 | static QQmlContextData *get(QQmlContext *context) { | - | ||||||||||||
161 | return executed 1471948 times by 140 tests: QQmlContextPrivate::get(context)->data;return QQmlContextPrivate::get(context)->data; Executed by:
executed 1471948 times by 140 tests: return QQmlContextPrivate::get(context)->data; Executed by:
| 1471948 | ||||||||||||
162 | } | - | ||||||||||||
163 | - | |||||||||||||
164 | private: | - | ||||||||||||
165 | friend class QQmlContextDataRef; | - | ||||||||||||
166 | friend class QQmlContext; | - | ||||||||||||
167 | void refreshExpressionsRecursive(bool isGlobal); | - | ||||||||||||
168 | void refreshExpressionsRecursive(QQmlJavaScriptExpression *); | - | ||||||||||||
169 | ~QQmlContextData(); | - | ||||||||||||
170 | void destroy(); | - | ||||||||||||
171 | }; | - | ||||||||||||
172 | - | |||||||||||||
173 | - | |||||||||||||
174 | class QQmlGuardedContextData | - | ||||||||||||
175 | { | - | ||||||||||||
176 | public: | - | ||||||||||||
177 | inline QQmlGuardedContextData() = default; | - | ||||||||||||
178 | inline QQmlGuardedContextData(QQmlContextData *data) | - | ||||||||||||
179 | { setContextData(data); } executed 136658 times by 142 tests: end of block Executed by:
| 136658 | ||||||||||||
180 | inline ~QQmlGuardedContextData() | - | ||||||||||||
181 | { clear(); } executed 383755 times by 142 tests: end of block Executed by:
| 383755 | ||||||||||||
182 | - | |||||||||||||
183 | inline QQmlContextData *contextData() const | - | ||||||||||||
184 | { return executed 4577 times by 11 tests: m_contextData;return m_contextData; Executed by:
executed 4577 times by 11 tests: }return m_contextData; Executed by:
| 4577 | ||||||||||||
185 | inline void setContextData(QQmlContextData *); | - | ||||||||||||
186 | - | |||||||||||||
187 | inline bool isNull() const { return executed 270732 times by 36 tests: !m_contextData;return !m_contextData; Executed by:
executed 270732 times by 36 tests: }return !m_contextData; Executed by:
| 270732 | ||||||||||||
188 | - | |||||||||||||
189 | inline operator QQmlContextData*() const { return executed 574550 times by 140 tests: m_contextData;return m_contextData; Executed by:
executed 574550 times by 140 tests: }return m_contextData; Executed by:
| 574550 | ||||||||||||
190 | inline QQmlContextData* operator->() const { return executed 632600 times by 140 tests: m_contextData;return m_contextData; Executed by:
executed 632600 times by 140 tests: }return m_contextData; Executed by:
| 632600 | ||||||||||||
191 | inline QQmlGuardedContextData &operator=(QQmlContextData *d) { | - | ||||||||||||
192 | setContextData(d); return executed 347195 times by 140 tests: *this;return *this; Executed by:
executed 347195 times by 140 tests: return *this; Executed by:
| 347195 | ||||||||||||
193 | } | - | ||||||||||||
194 | - | |||||||||||||
195 | private: | - | ||||||||||||
196 | QQmlGuardedContextData &operator=(const QQmlGuardedContextData &) = delete; | - | ||||||||||||
197 | QQmlGuardedContextData(const QQmlGuardedContextData &) = delete; | - | ||||||||||||
198 | friend class QQmlContextData; | - | ||||||||||||
199 | - | |||||||||||||
200 | inline void clear(); | - | ||||||||||||
201 | - | |||||||||||||
202 | QQmlContextData *m_contextData = nullptr; | - | ||||||||||||
203 | QQmlGuardedContextData *m_next = nullptr; | - | ||||||||||||
204 | QQmlGuardedContextData **m_prev = nullptr; | - | ||||||||||||
205 | }; | - | ||||||||||||
206 | - | |||||||||||||
207 | - | |||||||||||||
208 | void QQmlGuardedContextData::setContextData(QQmlContextData *contextData) | - | ||||||||||||
209 | { | - | ||||||||||||
210 | if (m_contextData == contextData
| 68779-415076 | ||||||||||||
211 | return; executed 68779 times by 142 tests: return; Executed by:
| 68779 | ||||||||||||
212 | clear(); | - | ||||||||||||
213 | - | |||||||||||||
214 | if (contextData
| 88699-326377 | ||||||||||||
215 | m_contextData = contextData; | - | ||||||||||||
216 | m_next = contextData->contextGuards; | - | ||||||||||||
217 | if (m_next
executed 117128 times by 68 tests: m_next->m_prev = &m_next; Executed by:
| 117128-209249 | ||||||||||||
218 | m_prev = &contextData->contextGuards; | - | ||||||||||||
219 | contextData->contextGuards = this; | - | ||||||||||||
220 | } executed 326377 times by 140 tests: end of block Executed by:
| 326377 | ||||||||||||
221 | } executed 415076 times by 140 tests: end of block Executed by:
| 415076 | ||||||||||||
222 | - | |||||||||||||
223 | void QQmlGuardedContextData::clear() | - | ||||||||||||
224 | { | - | ||||||||||||
225 | if (m_prev
| 319472-479359 | ||||||||||||
226 | *m_prev = m_next; | - | ||||||||||||
227 | if (m_next
executed 75847 times by 64 tests: m_next->m_prev = m_prev; Executed by:
| 75847-243625 | ||||||||||||
228 | m_contextData = nullptr; | - | ||||||||||||
229 | m_next = nullptr; | - | ||||||||||||
230 | m_prev = nullptr; | - | ||||||||||||
231 | } executed 319472 times by 113 tests: end of block Executed by:
| 319472 | ||||||||||||
232 | } executed 798831 times by 142 tests: end of block Executed by:
| 798831 | ||||||||||||
233 | - | |||||||||||||
234 | QQmlContextDataRef::QQmlContextDataRef() | - | ||||||||||||
235 | : m_contextData(nullptr) | - | ||||||||||||
236 | { | - | ||||||||||||
237 | } executed 253575 times by 149 tests: end of block Executed by:
| 253575 | ||||||||||||
238 | - | |||||||||||||
239 | QQmlContextDataRef::QQmlContextDataRef(const QQmlContextDataRef &other) | - | ||||||||||||
240 | : m_contextData(other.m_contextData) | - | ||||||||||||
241 | { | - | ||||||||||||
242 | if (m_contextData
| 0 | ||||||||||||
243 | ++ never executed: m_contextData->refCount;++m_contextData->refCount; never executed: ++m_contextData->refCount; | 0 | ||||||||||||
244 | } never executed: end of block | 0 | ||||||||||||
245 | - | |||||||||||||
246 | QQmlContextDataRef::QQmlContextDataRef(QQmlContextData *data) | - | ||||||||||||
247 | : m_contextData(data) | - | ||||||||||||
248 | { | - | ||||||||||||
249 | if (m_contextData
| 88443-1559849 | ||||||||||||
250 | ++ executed 1559849 times by 130 tests: m_contextData->refCount;++m_contextData->refCount; Executed by:
executed 1559849 times by 130 tests: ++m_contextData->refCount; Executed by:
| 1559849 | ||||||||||||
251 | } executed 1648292 times by 130 tests: end of block Executed by:
| 1648292 | ||||||||||||
252 | - | |||||||||||||
253 | QQmlContextDataRef::~QQmlContextDataRef() | - | ||||||||||||
254 | { | - | ||||||||||||
255 | clear(); | - | ||||||||||||
256 | } executed 1857691 times by 149 tests: end of block Executed by:
| 1857691 | ||||||||||||
257 | - | |||||||||||||
258 | void QQmlContextDataRef::setContextData(QQmlContextData *contextData) | - | ||||||||||||
259 | { | - | ||||||||||||
260 | if (m_contextData == contextData
| 209608-352891 | ||||||||||||
261 | return; executed 209608 times by 149 tests: return; Executed by:
| 209608 | ||||||||||||
262 | clear(); | - | ||||||||||||
263 | - | |||||||||||||
264 | if (contextData
| 111332-241559 | ||||||||||||
265 | m_contextData = contextData; | - | ||||||||||||
266 | ++m_contextData->refCount; | - | ||||||||||||
267 | } executed 241559 times by 140 tests: end of block Executed by:
| 241559 | ||||||||||||
268 | } executed 352891 times by 140 tests: end of block Executed by:
| 352891 | ||||||||||||
269 | - | |||||||||||||
270 | QQmlContextData *QQmlContextDataRef::contextData() const | - | ||||||||||||
271 | { | - | ||||||||||||
272 | return executed 4793617 times by 129 tests: m_contextData;return m_contextData; Executed by:
executed 4793617 times by 129 tests: return m_contextData; Executed by:
| 4793617 | ||||||||||||
273 | } | - | ||||||||||||
274 | - | |||||||||||||
275 | void QQmlContextDataRef::clear() | - | ||||||||||||
276 | { | - | ||||||||||||
277 | if (m_contextData
| 192255-1671177 | ||||||||||||
278 | m_contextData->destroy(); executed 192255 times by 128 tests: m_contextData->destroy(); Executed by:
| 192255 | ||||||||||||
279 | m_contextData = nullptr; | - | ||||||||||||
280 | } executed 2210582 times by 149 tests: end of block Executed by:
| 2210582 | ||||||||||||
281 | - | |||||||||||||
282 | QQmlContextDataRef & | - | ||||||||||||
283 | QQmlContextDataRef::operator=(QQmlContextData *d) | - | ||||||||||||
284 | { | - | ||||||||||||
285 | setContextData(d); | - | ||||||||||||
286 | return executed 562499 times by 149 tests: *this;return *this; Executed by:
executed 562499 times by 149 tests: return *this; Executed by:
| 562499 | ||||||||||||
287 | } | - | ||||||||||||
288 | - | |||||||||||||
289 | QQmlContextDataRef & | - | ||||||||||||
290 | QQmlContextDataRef::operator=(const QQmlContextDataRef &other) | - | ||||||||||||
291 | { | - | ||||||||||||
292 | setContextData(other.m_contextData); | - | ||||||||||||
293 | return never executed: *this;return *this; never executed: return *this; | 0 | ||||||||||||
294 | } | - | ||||||||||||
295 | - | |||||||||||||
296 | QQmlContextData::ContextGuard::ContextGuard() | - | ||||||||||||
297 | : context(nullptr) | - | ||||||||||||
298 | { | - | ||||||||||||
299 | } executed 218339 times by 115 tests: end of block Executed by:
| 218339 | ||||||||||||
300 | - | |||||||||||||
301 | QQmlContextData::ContextGuard &QQmlContextData::ContextGuard::operator=(QObject *obj) | - | ||||||||||||
302 | { | - | ||||||||||||
303 | QQmlGuard<QObject>::operator=(obj); | - | ||||||||||||
304 | context.setFlag(); | - | ||||||||||||
305 | bindings.notify(); | - | ||||||||||||
306 | return executed 218337 times by 115 tests: *this;return *this; Executed by:
executed 218337 times by 115 tests: return *this; Executed by:
| 218337 | ||||||||||||
307 | } | - | ||||||||||||
308 | - | |||||||||||||
309 | void QQmlContextData::ContextGuard::objectDestroyed(QObject *) | - | ||||||||||||
310 | { | - | ||||||||||||
311 | if (context->contextObject
| 28-210096 | ||||||||||||
312 | bindings.notify(); executed 28 times by 5 tests: bindings.notify(); Executed by:
| 28 | ||||||||||||
313 | } executed 210390 times by 108 tests: end of block Executed by:
| 210390 | ||||||||||||
314 | - | |||||||||||||
315 | bool QQmlContextData::ContextGuard::wasSet() const | - | ||||||||||||
316 | { | - | ||||||||||||
317 | return never executed: context.flag();return context.flag(); never executed: return context.flag(); | 0 | ||||||||||||
318 | } | - | ||||||||||||
319 | - | |||||||||||||
320 | - | |||||||||||||
Switch to Source code | Preprocessed file |