Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/qml/qqmlengine_p.h |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | - | |||||||||||||
8 | - | |||||||||||||
9 | - | |||||||||||||
10 | - | |||||||||||||
11 | - | |||||||||||||
12 | class QQmlContext; | - | ||||||||||||
13 | class QQmlEngine; | - | ||||||||||||
14 | class QQmlContextPrivate; | - | ||||||||||||
15 | class QQmlExpression; | - | ||||||||||||
16 | class QQmlImportDatabase; | - | ||||||||||||
17 | class QNetworkReply; | - | ||||||||||||
18 | class QNetworkAccessManager; | - | ||||||||||||
19 | class QQmlNetworkAccessManagerFactory; | - | ||||||||||||
20 | class QQmlTypeNameCache; | - | ||||||||||||
21 | class QQmlComponentAttached; | - | ||||||||||||
22 | class QQmlCleanup; | - | ||||||||||||
23 | class QQmlDelayedError; | - | ||||||||||||
24 | class QQuickWorkerScriptEngine; | - | ||||||||||||
25 | class QQmlObjectCreator; | - | ||||||||||||
26 | class QDir; | - | ||||||||||||
27 | class QQmlIncubator; | - | ||||||||||||
28 | class QQmlProfiler; | - | ||||||||||||
29 | class QQmlPropertyCapture; | - | ||||||||||||
30 | - | |||||||||||||
31 | - | |||||||||||||
32 | - | |||||||||||||
33 | class QQmlJavaScriptExpressionGuard : public QQmlNotifierEndpoint | - | ||||||||||||
34 | { | - | ||||||||||||
35 | public: | - | ||||||||||||
36 | inline QQmlJavaScriptExpressionGuard(QQmlJavaScriptExpression *); | - | ||||||||||||
37 | - | |||||||||||||
38 | static inline QQmlJavaScriptExpressionGuard *New(QQmlJavaScriptExpression *e, | - | ||||||||||||
39 | QQmlEngine *engine); | - | ||||||||||||
40 | inline void Delete(); | - | ||||||||||||
41 | - | |||||||||||||
42 | QQmlJavaScriptExpression *expression; | - | ||||||||||||
43 | QQmlJavaScriptExpressionGuard *next; | - | ||||||||||||
44 | }; | - | ||||||||||||
45 | - | |||||||||||||
46 | class __attribute__((visibility("default"))) QQmlEnginePrivate : public QJSEnginePrivate | - | ||||||||||||
47 | { | - | ||||||||||||
48 | inline QQmlEngine* q_func() { return static_cast<QQmlEngine *>(q_ptr); } inline const QQmlEngine* q_func() const { return static_cast<const QQmlEngine *>(q_ptr); } friend class QQmlEngine; | - | ||||||||||||
49 | public: | - | ||||||||||||
50 | QQmlEnginePrivate(QQmlEngine *); | - | ||||||||||||
51 | ~QQmlEnginePrivate() override; | - | ||||||||||||
52 | - | |||||||||||||
53 | void init(); | - | ||||||||||||
54 | - | |||||||||||||
55 | - | |||||||||||||
56 | static bool baseModulesUninitialized; | - | ||||||||||||
57 | - | |||||||||||||
58 | QQmlPropertyCapture *propertyCapture; | - | ||||||||||||
59 | - | |||||||||||||
60 | QRecyclePool<QQmlJavaScriptExpressionGuard> jsExpressionGuardPool; | - | ||||||||||||
61 | - | |||||||||||||
62 | QQmlContext *rootContext; | - | ||||||||||||
63 | - | |||||||||||||
64 | - | |||||||||||||
65 | - | |||||||||||||
66 | - | |||||||||||||
67 | QQmlProfiler *profiler; | - | ||||||||||||
68 | - | |||||||||||||
69 | - | |||||||||||||
70 | bool outputWarningsToMsgLog; | - | ||||||||||||
71 | - | |||||||||||||
72 | - | |||||||||||||
73 | QQmlCleanup *cleanup; | - | ||||||||||||
74 | - | |||||||||||||
75 | - | |||||||||||||
76 | QQmlDelayedError *erroredBindings; | - | ||||||||||||
77 | int inProgressCreations; | - | ||||||||||||
78 | - | |||||||||||||
79 | QV8Engine *v8engine() const { return executed 96928 times by 142 tests: q_func()->handle()->v8Engine;return q_func()->handle()->v8Engine; Executed by:
executed 96928 times by 142 tests: }return q_func()->handle()->v8Engine; Executed by:
| 96928 | ||||||||||||
80 | QV4::ExecutionEngine *v4engine() const { return executed 2123097 times by 140 tests: q_func()->handle();return q_func()->handle(); Executed by:
executed 2123097 times by 140 tests: }return q_func()->handle(); Executed by:
| 2123097 | ||||||||||||
81 | - | |||||||||||||
82 | QQuickWorkerScriptEngine *getWorkerScriptEngine(); | - | ||||||||||||
83 | QQuickWorkerScriptEngine *workerScriptEngine; | - | ||||||||||||
84 | - | |||||||||||||
85 | QUrl baseUrl; | - | ||||||||||||
86 | - | |||||||||||||
87 | typedef QPair<QPointer<QObject>,int> FinalizeCallback; | - | ||||||||||||
88 | void registerFinalizeCallback(QObject *obj, int index); | - | ||||||||||||
89 | - | |||||||||||||
90 | QQmlObjectCreator *activeObjectCreator; | - | ||||||||||||
91 | - | |||||||||||||
92 | QNetworkAccessManager *createNetworkAccessManager(QObject *parent) const; | - | ||||||||||||
93 | QNetworkAccessManager *getNetworkAccessManager() const; | - | ||||||||||||
94 | mutable QNetworkAccessManager *networkAccessManager; | - | ||||||||||||
95 | mutable QQmlNetworkAccessManagerFactory *networkAccessManagerFactory; | - | ||||||||||||
96 | - | |||||||||||||
97 | QHash<QString,QSharedPointer<QQmlImageProviderBase> > imageProviders; | - | ||||||||||||
98 | - | |||||||||||||
99 | QQmlAbstractUrlInterceptor* urlInterceptor; | - | ||||||||||||
100 | - | |||||||||||||
101 | int scarceResourcesRefCount; | - | ||||||||||||
102 | void referenceScarceResources(); | - | ||||||||||||
103 | void dereferenceScarceResources(); | - | ||||||||||||
104 | - | |||||||||||||
105 | QQmlImportDatabase importDatabase; | - | ||||||||||||
106 | QQmlTypeLoader typeLoader; | - | ||||||||||||
107 | - | |||||||||||||
108 | QString offlineStoragePath; | - | ||||||||||||
109 | - | |||||||||||||
110 | mutable quint32 uniqueId; | - | ||||||||||||
111 | inline quint32 getUniqueId() const { | - | ||||||||||||
112 | return never executed: uniqueId++;return uniqueId++; never executed: return uniqueId++; | 0 | ||||||||||||
113 | } | - | ||||||||||||
114 | - | |||||||||||||
115 | - | |||||||||||||
116 | - | |||||||||||||
117 | struct Incubator : public QSharedData { | - | ||||||||||||
118 | QIntrusiveListNode next; | - | ||||||||||||
119 | - | |||||||||||||
120 | QIntrusiveListNode nextWaitingFor; | - | ||||||||||||
121 | }; | - | ||||||||||||
122 | QIntrusiveList<Incubator, &Incubator::next> incubatorList; | - | ||||||||||||
123 | unsigned int incubatorCount; | - | ||||||||||||
124 | QQmlIncubationController *incubationController; | - | ||||||||||||
125 | void incubate(QQmlIncubator &, QQmlContextData *); | - | ||||||||||||
126 | - | |||||||||||||
127 | - | |||||||||||||
128 | inline bool isEngineThread() const; | - | ||||||||||||
129 | inline static bool isEngineThread(const QQmlEngine *); | - | ||||||||||||
130 | template<typename T> | - | ||||||||||||
131 | inline void deleteInEngineThread(T *); | - | ||||||||||||
132 | template<typename T> | - | ||||||||||||
133 | inline static void deleteInEngineThread(QQmlEnginePrivate *, T *); | - | ||||||||||||
134 | QString offlineStorageDatabaseDirectory() const; | - | ||||||||||||
135 | - | |||||||||||||
136 | - | |||||||||||||
137 | inline QQmlPropertyCache *cache(const QQmlType &, int); | - | ||||||||||||
138 | using QJSEnginePrivate::cache; | - | ||||||||||||
139 | - | |||||||||||||
140 | - | |||||||||||||
141 | bool isQObject(int); | - | ||||||||||||
142 | QObject *toQObject(const QVariant &, bool *ok = nullptr) const; | - | ||||||||||||
143 | QQmlMetaType::TypeCategory typeCategory(int) const; | - | ||||||||||||
144 | bool isList(int) const; | - | ||||||||||||
145 | int listType(int) const; | - | ||||||||||||
146 | QQmlMetaObject rawMetaObjectForType(int) const; | - | ||||||||||||
147 | QQmlMetaObject metaObjectForType(int) const; | - | ||||||||||||
148 | QQmlPropertyCache *propertyCacheForType(int); | - | ||||||||||||
149 | QQmlPropertyCache *rawPropertyCacheForType(int, int minorVersion = -1); | - | ||||||||||||
150 | void registerInternalCompositeType(QV4::CompiledData::CompilationUnit *compilationUnit); | - | ||||||||||||
151 | void unregisterInternalCompositeType(QV4::CompiledData::CompilationUnit *compilationUnit); | - | ||||||||||||
152 | - | |||||||||||||
153 | bool isTypeLoaded(const QUrl &url) const; | - | ||||||||||||
154 | bool isScriptLoaded(const QUrl &url) const; | - | ||||||||||||
155 | - | |||||||||||||
156 | void sendQuit(); | - | ||||||||||||
157 | void sendExit(int retCode = 0); | - | ||||||||||||
158 | void warning(const QQmlError &); | - | ||||||||||||
159 | void warning(const QList<QQmlError> &); | - | ||||||||||||
160 | static void warning(QQmlEngine *, const QQmlError &); | - | ||||||||||||
161 | static void warning(QQmlEngine *, const QList<QQmlError> &); | - | ||||||||||||
162 | static void warning(QQmlEnginePrivate *, const QQmlError &); | - | ||||||||||||
163 | static void warning(QQmlEnginePrivate *, const QList<QQmlError> &); | - | ||||||||||||
164 | - | |||||||||||||
165 | inline static QV8Engine *getV8Engine(QQmlEngine *e); | - | ||||||||||||
166 | inline static QV4::ExecutionEngine *getV4Engine(QQmlEngine *e); | - | ||||||||||||
167 | inline static QQmlEnginePrivate *get(QQmlEngine *e); | - | ||||||||||||
168 | inline static const QQmlEnginePrivate *get(const QQmlEngine *e); | - | ||||||||||||
169 | inline static QQmlEnginePrivate *get(QQmlContext *c); | - | ||||||||||||
170 | inline static QQmlEnginePrivate *get(QQmlContextData *c); | - | ||||||||||||
171 | inline static QQmlEngine *get(QQmlEnginePrivate *p); | - | ||||||||||||
172 | inline static QQmlEnginePrivate *get(QV4::ExecutionEngine *e); | - | ||||||||||||
173 | - | |||||||||||||
174 | static void registerBaseTypes(const char *uri, int versionMajor, int versionMinor); | - | ||||||||||||
175 | static void registerQtQuick2Types(const char *uri, int versionMajor, int versionMinor); | - | ||||||||||||
176 | static void defineQtQuick2Module(); | - | ||||||||||||
177 | - | |||||||||||||
178 | static bool designerMode(); | - | ||||||||||||
179 | static void activateDesignerMode(); | - | ||||||||||||
180 | - | |||||||||||||
181 | static bool qml_debugging_enabled; | - | ||||||||||||
182 | - | |||||||||||||
183 | mutable QMutex networkAccessManagerMutex; | - | ||||||||||||
184 | - | |||||||||||||
185 | private: | - | ||||||||||||
186 | - | |||||||||||||
187 | - | |||||||||||||
188 | QHash<int, QV4::CompiledData::CompilationUnit *> m_compositeTypes; | - | ||||||||||||
189 | static bool s_designerMode; | - | ||||||||||||
190 | - | |||||||||||||
191 | - | |||||||||||||
192 | struct Deletable { Deletable():next(nullptr) {} never executed: virtual ~Deletable() {} Deletable *next; };end of block | 0 | ||||||||||||
193 | QFieldList<Deletable, &Deletable::next> toDeleteInEngineThread; | - | ||||||||||||
194 | void doDeleteInEngineThread(); | - | ||||||||||||
195 | - | |||||||||||||
196 | void cleanupScarceResources(); | - | ||||||||||||
197 | }; | - | ||||||||||||
198 | - | |||||||||||||
199 | - | |||||||||||||
200 | - | |||||||||||||
201 | - | |||||||||||||
202 | - | |||||||||||||
203 | - | |||||||||||||
204 | inline void QQmlEnginePrivate::referenceScarceResources() | - | ||||||||||||
205 | { | - | ||||||||||||
206 | scarceResourcesRefCount += 1; | - | ||||||||||||
207 | } executed 2179104 times by 140 tests: end of block Executed by:
| 2179104 | ||||||||||||
208 | - | |||||||||||||
209 | - | |||||||||||||
210 | - | |||||||||||||
211 | - | |||||||||||||
212 | - | |||||||||||||
213 | inline void QQmlEnginePrivate::dereferenceScarceResources() | - | ||||||||||||
214 | { | - | ||||||||||||
215 | ((scarceResourcesRefCount > 0) ? static_cast<void>(0) : qt_assert("scarceResourcesRefCount > 0", __FILE__, 289)); | - | ||||||||||||
216 | scarceResourcesRefCount -= 1; | - | ||||||||||||
217 | - | |||||||||||||
218 | - | |||||||||||||
219 | - | |||||||||||||
220 | - | |||||||||||||
221 | if (__builtin_expect(!!(scarceResourcesRefCount == 0), true)
| 56007-2123097 | ||||||||||||
222 | QV4::ExecutionEngine *engine = v4engine(); | - | ||||||||||||
223 | if (__builtin_expect(!!(!engine->scarceResources.isEmpty()), false)
| 36-2123061 | ||||||||||||
224 | cleanupScarceResources(); | - | ||||||||||||
225 | } executed 36 times by 1 test: end of block Executed by:
| 36 | ||||||||||||
226 | } executed 2123097 times by 140 tests: end of block Executed by:
| 2123097 | ||||||||||||
227 | } executed 2179104 times by 140 tests: end of block Executed by:
| 2179104 | ||||||||||||
228 | - | |||||||||||||
229 | - | |||||||||||||
230 | - | |||||||||||||
231 | - | |||||||||||||
232 | bool QQmlEnginePrivate::isEngineThread() const | - | ||||||||||||
233 | { | - | ||||||||||||
234 | const QQmlEngine * const q = q_func(); | - | ||||||||||||
235 | return executed 6090 times by 63 tests: QThread::currentThread() == q->thread();return QThread::currentThread() == q->thread(); Executed by:
executed 6090 times by 63 tests: return QThread::currentThread() == q->thread(); Executed by:
| 6090 | ||||||||||||
236 | } | - | ||||||||||||
237 | - | |||||||||||||
238 | - | |||||||||||||
239 | - | |||||||||||||
240 | - | |||||||||||||
241 | bool QQmlEnginePrivate::isEngineThread(const QQmlEngine *engine) | - | ||||||||||||
242 | { | - | ||||||||||||
243 | ((engine) ? static_cast<void>(0) : qt_assert("engine", __FILE__, 317)); | - | ||||||||||||
244 | return executed 741 times by 17 tests: QQmlEnginePrivate::get(engine)->isEngineThread();return QQmlEnginePrivate::get(engine)->isEngineThread(); Executed by:
executed 741 times by 17 tests: return QQmlEnginePrivate::get(engine)->isEngineThread(); Executed by:
| 741 | ||||||||||||
245 | } | - | ||||||||||||
246 | template<typename T> | - | ||||||||||||
247 | void QQmlEnginePrivate::deleteInEngineThread(T *value) | - | ||||||||||||
248 | { | - | ||||||||||||
249 | QQmlEngine * const q = q_func(); | - | ||||||||||||
250 | - | |||||||||||||
251 | ((value) ? static_cast<void>(0) : qt_assert("value", __FILE__, 336)); | - | ||||||||||||
252 | if (isEngineThread()
| 0-5349 | ||||||||||||
253 | delete value; | - | ||||||||||||
254 | } executed 5349 times by 54 tests: else {end of block Executed by:
| 5349 | ||||||||||||
255 | struct I : public Deletable { | - | ||||||||||||
256 | I(T *value) : value(value) {} never executed: end of block | 0 | ||||||||||||
257 | ~I() override { delete value; } never executed: end of block | 0 | ||||||||||||
258 | T *value; | - | ||||||||||||
259 | }; | - | ||||||||||||
260 | I *i = new I(value); | - | ||||||||||||
261 | mutex.lock(); | - | ||||||||||||
262 | bool wasEmpty = toDeleteInEngineThread.isEmpty(); | - | ||||||||||||
263 | toDeleteInEngineThread.append(i); | - | ||||||||||||
264 | mutex.unlock(); | - | ||||||||||||
265 | if (wasEmpty
| 0 | ||||||||||||
266 | QCoreApplication::postEvent(q, new QEvent(QEvent::User)); never executed: QCoreApplication::postEvent(q, new QEvent(QEvent::User)); | 0 | ||||||||||||
267 | } never executed: end of block | 0 | ||||||||||||
268 | } | - | ||||||||||||
269 | - | |||||||||||||
270 | - | |||||||||||||
271 | - | |||||||||||||
272 | - | |||||||||||||
273 | - | |||||||||||||
274 | template<typename T> | - | ||||||||||||
275 | void QQmlEnginePrivate::deleteInEngineThread(QQmlEnginePrivate *engine, T *value) | - | ||||||||||||
276 | { | - | ||||||||||||
277 | ((engine) ? static_cast<void>(0) : qt_assert("engine", __FILE__, 362)); | - | ||||||||||||
278 | engine->deleteInEngineThread<T>(value); | - | ||||||||||||
279 | } executed 5349 times by 54 tests: end of block Executed by:
| 5349 | ||||||||||||
280 | - | |||||||||||||
281 | - | |||||||||||||
282 | - | |||||||||||||
283 | - | |||||||||||||
284 | - | |||||||||||||
285 | - | |||||||||||||
286 | QQmlPropertyCache *QQmlEnginePrivate::cache(const QQmlType &type, int minorVersion) | - | ||||||||||||
287 | { | - | ||||||||||||
288 | ((type.isValid()) ? static_cast<void>(0) : qt_assert("type.isValid()", __FILE__, 373)); | - | ||||||||||||
289 | - | |||||||||||||
290 | if (minorVersion == -1
| 0-63065 | ||||||||||||
291 | return never executed: cache(type.metaObject());return cache(type.metaObject()); never executed: return cache(type.metaObject()); | 0 | ||||||||||||
292 | - | |||||||||||||
293 | Locker locker(this); | - | ||||||||||||
294 | return executed 63065 times by 134 tests: QQmlMetaType::propertyCache(type, minorVersion);return QQmlMetaType::propertyCache(type, minorVersion); Executed by:
executed 63065 times by 134 tests: return QQmlMetaType::propertyCache(type, minorVersion); Executed by:
| 63065 | ||||||||||||
295 | } | - | ||||||||||||
296 | - | |||||||||||||
297 | QV8Engine *QQmlEnginePrivate::getV8Engine(QQmlEngine *e) | - | ||||||||||||
298 | { | - | ||||||||||||
299 | ((e) ? static_cast<void>(0) : qt_assert("e", __FILE__, 384)); | - | ||||||||||||
300 | - | |||||||||||||
301 | return never executed: e->handle()->v8Engine;return e->handle()->v8Engine; never executed: return e->handle()->v8Engine; | 0 | ||||||||||||
302 | } | - | ||||||||||||
303 | - | |||||||||||||
304 | QV4::ExecutionEngine *QQmlEnginePrivate::getV4Engine(QQmlEngine *e) | - | ||||||||||||
305 | { | - | ||||||||||||
306 | ((e) ? static_cast<void>(0) : qt_assert("e", __FILE__, 391)); | - | ||||||||||||
307 | - | |||||||||||||
308 | return never executed: e->handle();return e->handle(); never executed: return e->handle(); | 0 | ||||||||||||
309 | } | - | ||||||||||||
310 | - | |||||||||||||
311 | QQmlEnginePrivate *QQmlEnginePrivate::get(QQmlEngine *e) | - | ||||||||||||
312 | { | - | ||||||||||||
313 | ((e) ? static_cast<void>(0) : qt_assert("e", __FILE__, 398)); | - | ||||||||||||
314 | - | |||||||||||||
315 | return executed 15920789 times by 145 tests: e->d_func();return e->d_func(); Executed by:
executed 15920789 times by 145 tests: return e->d_func(); Executed by:
| 15920789 | ||||||||||||
316 | } | - | ||||||||||||
317 | - | |||||||||||||
318 | const QQmlEnginePrivate *QQmlEnginePrivate::get(const QQmlEngine *e) | - | ||||||||||||
319 | { | - | ||||||||||||
320 | ((e) ? static_cast<void>(0) : qt_assert("e", __FILE__, 405)); | - | ||||||||||||
321 | - | |||||||||||||
322 | return executed 741 times by 17 tests: e ? e->d_func() : nullptr;return e ? e->d_func() : nullptr; Executed by:
executed 741 times by 17 tests: return e ? e->d_func() : nullptr; Executed by:
| 741 | ||||||||||||
323 | } | - | ||||||||||||
324 | - | |||||||||||||
325 | QQmlEnginePrivate *QQmlEnginePrivate::get(QQmlContext *c) | - | ||||||||||||
326 | { | - | ||||||||||||
327 | return executed 76 times by 4 tests: (c && c->engine()) ? QQmlEnginePrivate::get(c->engine()) : nullptr;return (c && c->engine()) ? QQmlEnginePrivate::get(c->engine()) : nullptr; Executed by:
executed 76 times by 4 tests: return (c && c->engine()) ? QQmlEnginePrivate::get(c->engine()) : nullptr; Executed by:
| 76 | ||||||||||||
328 | } | - | ||||||||||||
329 | - | |||||||||||||
330 | QQmlEnginePrivate *QQmlEnginePrivate::get(QQmlContextData *c) | - | ||||||||||||
331 | { | - | ||||||||||||
332 | return executed 998205 times by 126 tests: (c && c->engine) ? QQmlEnginePrivate::get(c->engine) : nullptr;return (c && c->engine) ? QQmlEnginePrivate::get(c->engine) : nullptr; Executed by:
executed 998205 times by 126 tests: return (c && c->engine) ? QQmlEnginePrivate::get(c->engine) : nullptr; Executed by:
| 998205 | ||||||||||||
333 | } | - | ||||||||||||
334 | - | |||||||||||||
335 | QQmlEngine *QQmlEnginePrivate::get(QQmlEnginePrivate *p) | - | ||||||||||||
336 | { | - | ||||||||||||
337 | ((p) ? static_cast<void>(0) : qt_assert("p", __FILE__, 422)); | - | ||||||||||||
338 | - | |||||||||||||
339 | return executed 116985 times by 142 tests: p->q_func();return p->q_func(); Executed by:
executed 116985 times by 142 tests: return p->q_func(); Executed by:
| 116985 | ||||||||||||
340 | } | - | ||||||||||||
341 | - | |||||||||||||
342 | QQmlEnginePrivate *QQmlEnginePrivate::get(QV4::ExecutionEngine *e) | - | ||||||||||||
343 | { | - | ||||||||||||
344 | QQmlEngine *qmlEngine = e->qmlEngine(); | - | ||||||||||||
345 | if (!qmlEngine
| 0-890762 | ||||||||||||
346 | return never executed: nullptr;return nullptr; never executed: return nullptr; | 0 | ||||||||||||
347 | return executed 890762 times by 121 tests: get(qmlEngine);return get(qmlEngine); Executed by:
executed 890762 times by 121 tests: return get(qmlEngine); Executed by:
| 890762 | ||||||||||||
348 | } | - | ||||||||||||
349 | - | |||||||||||||
350 | - | |||||||||||||
Switch to Source code | Preprocessed file |