Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/qml/ftw/qqmlthread.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||
2 | ** | - | ||||||||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||
5 | ** | - | ||||||||||||
6 | ** This file is part of the QtQml module of the Qt Toolkit. | - | ||||||||||||
7 | ** | - | ||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||
16 | ** | - | ||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||
24 | ** | - | ||||||||||||
25 | ** GNU General Public License Usage | - | ||||||||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||
35 | ** | - | ||||||||||||
36 | ** $QT_END_LICENSE$ | - | ||||||||||||
37 | ** | - | ||||||||||||
38 | ****************************************************************************/ | - | ||||||||||||
39 | - | |||||||||||||
40 | #include "qqmlthread_p.h" | - | ||||||||||||
41 | - | |||||||||||||
42 | #include <private/qfieldlist_p.h> | - | ||||||||||||
43 | - | |||||||||||||
44 | #include <QtCore/qmutex.h> | - | ||||||||||||
45 | #include <QtCore/qthread.h> | - | ||||||||||||
46 | #include <QtCore/qcoreevent.h> | - | ||||||||||||
47 | #include <QtCore/qwaitcondition.h> | - | ||||||||||||
48 | #include <QtCore/qcoreapplication.h> | - | ||||||||||||
49 | - | |||||||||||||
50 | QT_BEGIN_NAMESPACE | - | ||||||||||||
51 | - | |||||||||||||
52 | class QQmlThreadPrivate : public QThread | - | ||||||||||||
53 | { | - | ||||||||||||
54 | public: | - | ||||||||||||
55 | QQmlThreadPrivate(QQmlThread *); | - | ||||||||||||
56 | QQmlThread *q; | - | ||||||||||||
57 | - | |||||||||||||
58 | void run() override; | - | ||||||||||||
59 | - | |||||||||||||
60 | inline QMutex &mutex() { return _mutex; } executed 7674 times by 148 tests: return _mutex; Executed by:
| 7674 | ||||||||||||
61 | inline void lock() { _mutex.lock(); } executed 332179 times by 148 tests: end of block Executed by:
| 332179 | ||||||||||||
62 | inline void unlock() { _mutex.unlock(); } executed 332179 times by 148 tests: end of block Executed by:
| 332179 | ||||||||||||
63 | inline void wait() { _wait.wait(&_mutex); } executed 84351 times by 148 tests: end of block Executed by:
| 84351 | ||||||||||||
64 | inline void wakeOne() { _wait.wakeOne(); } executed 84445 times by 148 tests: end of block Executed by:
| 84445 | ||||||||||||
65 | inline void wakeAll() { _wait.wakeAll(); } never executed: end of block | 0 | ||||||||||||
66 | - | |||||||||||||
67 | quint32 m_threadProcessing:1; // Set when the thread is processing messages | - | ||||||||||||
68 | quint32 m_mainProcessing:1; // Set when the main thread is processing messages | - | ||||||||||||
69 | quint32 m_shutdown:1; // Set by main thread to request a shutdown | - | ||||||||||||
70 | quint32 m_mainThreadWaiting:1; // Set by main thread if it is waiting for the message queue to empty | - | ||||||||||||
71 | - | |||||||||||||
72 | typedef QFieldList<QQmlThread::Message, &QQmlThread::Message::next> MessageList; | - | ||||||||||||
73 | MessageList threadList; | - | ||||||||||||
74 | MessageList mainList; | - | ||||||||||||
75 | - | |||||||||||||
76 | QQmlThread::Message *mainSync; | - | ||||||||||||
77 | - | |||||||||||||
78 | void triggerMainEvent(); | - | ||||||||||||
79 | void triggerThreadEvent(); | - | ||||||||||||
80 | - | |||||||||||||
81 | void mainEvent(); | - | ||||||||||||
82 | void threadEvent(); | - | ||||||||||||
83 | - | |||||||||||||
84 | protected: | - | ||||||||||||
85 | bool event(QEvent *) override; | - | ||||||||||||
86 | - | |||||||||||||
87 | private: | - | ||||||||||||
88 | struct MainObject : public QObject { | - | ||||||||||||
89 | MainObject(QQmlThreadPrivate *p); | - | ||||||||||||
90 | bool event(QEvent *e) override; | - | ||||||||||||
91 | QQmlThreadPrivate *p; | - | ||||||||||||
92 | }; | - | ||||||||||||
93 | MainObject m_mainObject; | - | ||||||||||||
94 | - | |||||||||||||
95 | QMutex _mutex; | - | ||||||||||||
96 | QWaitCondition _wait; | - | ||||||||||||
97 | }; | - | ||||||||||||
98 | - | |||||||||||||
99 | QQmlThreadPrivate::MainObject::MainObject(QQmlThreadPrivate *p) | - | ||||||||||||
100 | : p(p) | - | ||||||||||||
101 | { | - | ||||||||||||
102 | } executed 7674 times by 148 tests: end of block Executed by:
| 7674 | ||||||||||||
103 | - | |||||||||||||
104 | // Trigger mainEvent in main thread. Must be called from thread. | - | ||||||||||||
105 | void QQmlThreadPrivate::triggerMainEvent() | - | ||||||||||||
106 | { | - | ||||||||||||
107 | Q_ASSERT(q->isThisThread()); | - | ||||||||||||
108 | QCoreApplication::postEvent(&m_mainObject, new QEvent(QEvent::User)); | - | ||||||||||||
109 | } executed 9006 times by 141 tests: end of block Executed by:
| 9006 | ||||||||||||
110 | - | |||||||||||||
111 | // Trigger even in thread. Must be called from main thread. | - | ||||||||||||
112 | void QQmlThreadPrivate::triggerThreadEvent() | - | ||||||||||||
113 | { | - | ||||||||||||
114 | Q_ASSERT(!q->isThisThread()); | - | ||||||||||||
115 | QCoreApplication::postEvent(this, new QEvent(QEvent::User)); | - | ||||||||||||
116 | } executed 62035 times by 148 tests: end of block Executed by:
| 62035 | ||||||||||||
117 | - | |||||||||||||
118 | bool QQmlThreadPrivate::MainObject::event(QEvent *e) | - | ||||||||||||
119 | { | - | ||||||||||||
120 | if (e->type() == QEvent::User)
| 0-6408 | ||||||||||||
121 | p->mainEvent(); executed 6408 times by 110 tests: p->mainEvent(); Executed by:
| 6408 | ||||||||||||
122 | return QObject::event(e); executed 6408 times by 110 tests: return QObject::event(e); Executed by:
| 6408 | ||||||||||||
123 | } | - | ||||||||||||
124 | - | |||||||||||||
125 | QQmlThreadPrivate::QQmlThreadPrivate(QQmlThread *q) | - | ||||||||||||
126 | : q(q), m_threadProcessing(false), m_mainProcessing(false), m_shutdown(false), | - | ||||||||||||
127 | m_mainThreadWaiting(false), mainSync(nullptr), m_mainObject(this) | - | ||||||||||||
128 | { | - | ||||||||||||
129 | setObjectName(QStringLiteral("QQmlThread")); executed 7674 times by 148 tests: return qstring_literal_temp; Executed by:
| 7674 | ||||||||||||
130 | } executed 7674 times by 148 tests: end of block Executed by:
| 7674 | ||||||||||||
131 | - | |||||||||||||
132 | bool QQmlThreadPrivate::event(QEvent *e) | - | ||||||||||||
133 | { | - | ||||||||||||
134 | if (e->type() == QEvent::User)
| 7674-62035 | ||||||||||||
135 | threadEvent(); executed 62035 times by 148 tests: threadEvent(); Executed by:
| 62035 | ||||||||||||
136 | return QThread::event(e); executed 69709 times by 148 tests: return QThread::event(e); Executed by:
| 69709 | ||||||||||||
137 | } | - | ||||||||||||
138 | - | |||||||||||||
139 | void QQmlThreadPrivate::run() | - | ||||||||||||
140 | { | - | ||||||||||||
141 | lock(); | - | ||||||||||||
142 | - | |||||||||||||
143 | wakeOne(); | - | ||||||||||||
144 | - | |||||||||||||
145 | unlock(); | - | ||||||||||||
146 | - | |||||||||||||
147 | q->startupThread(); | - | ||||||||||||
148 | exec(); | - | ||||||||||||
149 | q->shutdownThread(); | - | ||||||||||||
150 | } executed 7660 times by 148 tests: end of block Executed by:
| 7660 | ||||||||||||
151 | - | |||||||||||||
152 | void QQmlThreadPrivate::mainEvent() | - | ||||||||||||
153 | { | - | ||||||||||||
154 | lock(); | - | ||||||||||||
155 | - | |||||||||||||
156 | m_mainProcessing = true; | - | ||||||||||||
157 | - | |||||||||||||
158 | while (!mainList.isEmpty() || mainSync) {
| 19-55680 | ||||||||||||
159 | bool isSync = mainSync != nullptr; | - | ||||||||||||
160 | QQmlThread::Message *message = isSync?mainSync:mainList.takeFirst();
| 40-55659 | ||||||||||||
161 | unlock(); | - | ||||||||||||
162 | - | |||||||||||||
163 | message->call(q); | - | ||||||||||||
164 | delete message; | - | ||||||||||||
165 | - | |||||||||||||
166 | lock(); | - | ||||||||||||
167 | - | |||||||||||||
168 | if (isSync) {
| 40-55659 | ||||||||||||
169 | mainSync = nullptr; | - | ||||||||||||
170 | wakeOne(); | - | ||||||||||||
171 | } executed 40 times by 7 tests: end of block Executed by:
| 40 | ||||||||||||
172 | } executed 55699 times by 141 tests: end of block Executed by:
| 55699 | ||||||||||||
173 | - | |||||||||||||
174 | m_mainProcessing = false; | - | ||||||||||||
175 | - | |||||||||||||
176 | unlock(); | - | ||||||||||||
177 | } executed 9004 times by 141 tests: end of block Executed by:
| 9004 | ||||||||||||
178 | - | |||||||||||||
179 | void QQmlThreadPrivate::threadEvent() | - | ||||||||||||
180 | { | - | ||||||||||||
181 | lock(); | - | ||||||||||||
182 | - | |||||||||||||
183 | for (;;) { | - | ||||||||||||
184 | if (m_shutdown) {
| 7660-108762 | ||||||||||||
185 | quit(); | - | ||||||||||||
186 | wakeOne(); | - | ||||||||||||
187 | unlock(); | - | ||||||||||||
188 | - | |||||||||||||
189 | return; executed 7660 times by 148 tests: return; Executed by:
| 7660 | ||||||||||||
190 | } else if (!threadList.isEmpty()) {
| 54375-54387 | ||||||||||||
191 | m_threadProcessing = true; | - | ||||||||||||
192 | - | |||||||||||||
193 | QQmlThread::Message *message = threadList.first(); | - | ||||||||||||
194 | - | |||||||||||||
195 | unlock(); | - | ||||||||||||
196 | - | |||||||||||||
197 | message->call(q); | - | ||||||||||||
198 | - | |||||||||||||
199 | lock(); | - | ||||||||||||
200 | - | |||||||||||||
201 | delete threadList.takeFirst(); | - | ||||||||||||
202 | } else { executed 54387 times by 141 tests: end of block Executed by:
| 54387 | ||||||||||||
203 | wakeOne(); | - | ||||||||||||
204 | - | |||||||||||||
205 | m_threadProcessing = false; | - | ||||||||||||
206 | - | |||||||||||||
207 | unlock(); | - | ||||||||||||
208 | - | |||||||||||||
209 | return; executed 54375 times by 141 tests: return; Executed by:
| 54375 | ||||||||||||
210 | } | - | ||||||||||||
211 | } | - | ||||||||||||
212 | } never executed: end of block | 0 | ||||||||||||
213 | - | |||||||||||||
214 | QQmlThread::QQmlThread() | - | ||||||||||||
215 | : d(new QQmlThreadPrivate(this)) | - | ||||||||||||
216 | { | - | ||||||||||||
217 | } executed 7674 times by 148 tests: end of block Executed by:
| 7674 | ||||||||||||
218 | - | |||||||||||||
219 | QQmlThread::~QQmlThread() | - | ||||||||||||
220 | { | - | ||||||||||||
221 | delete d; | - | ||||||||||||
222 | } executed 7660 times by 148 tests: end of block Executed by:
| 7660 | ||||||||||||
223 | - | |||||||||||||
224 | void QQmlThread::startup() | - | ||||||||||||
225 | { | - | ||||||||||||
226 | d->lock(); | - | ||||||||||||
227 | d->start(); | - | ||||||||||||
228 | d->wait(); | - | ||||||||||||
229 | d->unlock(); | - | ||||||||||||
230 | d->moveToThread(d); | - | ||||||||||||
231 | } executed 7674 times by 148 tests: end of block Executed by:
| 7674 | ||||||||||||
232 | - | |||||||||||||
233 | void QQmlThread::shutdown() | - | ||||||||||||
234 | { | - | ||||||||||||
235 | d->lock(); | - | ||||||||||||
236 | Q_ASSERT(!d->m_shutdown); | - | ||||||||||||
237 | - | |||||||||||||
238 | for (;;) { | - | ||||||||||||
239 | if (d->mainSync || !d->mainList.isEmpty()) {
| 0-10256 | ||||||||||||
240 | d->unlock(); | - | ||||||||||||
241 | d->mainEvent(); | - | ||||||||||||
242 | d->lock(); | - | ||||||||||||
243 | } else if (!d->threadList.isEmpty()) { executed 2596 times by 83 tests: end of block Executed by:
| 0-7660 | ||||||||||||
244 | d->wait(); | - | ||||||||||||
245 | } else { never executed: end of block | 0 | ||||||||||||
246 | break; executed 7660 times by 148 tests: break; Executed by:
| 7660 | ||||||||||||
247 | } | - | ||||||||||||
248 | } | - | ||||||||||||
249 | - | |||||||||||||
250 | d->m_shutdown = true; | - | ||||||||||||
251 | if (QCoreApplication::closingDown()) {
| 0-7660 | ||||||||||||
252 | d->quit(); | - | ||||||||||||
253 | } else { never executed: end of block | 0 | ||||||||||||
254 | d->triggerThreadEvent(); | - | ||||||||||||
255 | d->wait(); | - | ||||||||||||
256 | } executed 7660 times by 148 tests: end of block Executed by:
| 7660 | ||||||||||||
257 | - | |||||||||||||
258 | d->unlock(); | - | ||||||||||||
259 | d->QThread::wait(); | - | ||||||||||||
260 | } executed 7660 times by 148 tests: end of block Executed by:
| 7660 | ||||||||||||
261 | - | |||||||||||||
262 | bool QQmlThread::isShutdown() const | - | ||||||||||||
263 | { | - | ||||||||||||
264 | return d->m_shutdown; executed 17416 times by 148 tests: return d->m_shutdown; Executed by:
| 17416 | ||||||||||||
265 | } | - | ||||||||||||
266 | - | |||||||||||||
267 | QMutex &QQmlThread::mutex() | - | ||||||||||||
268 | { | - | ||||||||||||
269 | return d->mutex(); executed 7674 times by 148 tests: return d->mutex(); Executed by:
| 7674 | ||||||||||||
270 | } | - | ||||||||||||
271 | - | |||||||||||||
272 | void QQmlThread::lock() | - | ||||||||||||
273 | { | - | ||||||||||||
274 | d->lock(); | - | ||||||||||||
275 | } executed 7349 times by 133 tests: end of block Executed by:
| 7349 | ||||||||||||
276 | - | |||||||||||||
277 | void QQmlThread::unlock() | - | ||||||||||||
278 | { | - | ||||||||||||
279 | d->unlock(); | - | ||||||||||||
280 | } executed 7349 times by 133 tests: end of block Executed by:
| 7349 | ||||||||||||
281 | - | |||||||||||||
282 | void QQmlThread::wakeOne() | - | ||||||||||||
283 | { | - | ||||||||||||
284 | d->wakeOne(); | - | ||||||||||||
285 | } executed 7349 times by 133 tests: end of block Executed by:
| 7349 | ||||||||||||
286 | - | |||||||||||||
287 | void QQmlThread::wakeAll() | - | ||||||||||||
288 | { | - | ||||||||||||
289 | d->wakeAll(); | - | ||||||||||||
290 | } never executed: end of block | 0 | ||||||||||||
291 | - | |||||||||||||
292 | void QQmlThread::wait() | - | ||||||||||||
293 | { | - | ||||||||||||
294 | d->wait(); | - | ||||||||||||
295 | } never executed: end of block | 0 | ||||||||||||
296 | - | |||||||||||||
297 | bool QQmlThread::isThisThread() const | - | ||||||||||||
298 | { | - | ||||||||||||
299 | return QThread::currentThread() == d; executed 265077 times by 148 tests: return QThread::currentThread() == d; Executed by:
| 265077 | ||||||||||||
300 | } | - | ||||||||||||
301 | - | |||||||||||||
302 | QThread *QQmlThread::thread() const | - | ||||||||||||
303 | { | - | ||||||||||||
304 | return const_cast<QThread *>(static_cast<const QThread *>(d)); never executed: return const_cast<QThread *>(static_cast<const QThread *>(d)); | 0 | ||||||||||||
305 | } | - | ||||||||||||
306 | - | |||||||||||||
307 | // Called when the thread starts. Do startup stuff in here. | - | ||||||||||||
308 | void QQmlThread::startupThread() | - | ||||||||||||
309 | { | - | ||||||||||||
310 | } | - | ||||||||||||
311 | - | |||||||||||||
312 | // Called when the thread shuts down. Do cleanup in here. | - | ||||||||||||
313 | void QQmlThread::shutdownThread() | - | ||||||||||||
314 | { | - | ||||||||||||
315 | } | - | ||||||||||||
316 | - | |||||||||||||
317 | void QQmlThread::internalCallMethodInThread(Message *message) | - | ||||||||||||
318 | { | - | ||||||||||||
319 | Q_ASSERT(!isThisThread()); | - | ||||||||||||
320 | d->lock(); | - | ||||||||||||
321 | Q_ASSERT(d->m_mainThreadWaiting == false); | - | ||||||||||||
322 | - | |||||||||||||
323 | bool wasEmpty = d->threadList.isEmpty(); | - | ||||||||||||
324 | d->threadList.append(message); | - | ||||||||||||
325 | if (wasEmpty && d->m_threadProcessing == false)
| 0-54271 | ||||||||||||
326 | d->triggerThreadEvent(); executed 54271 times by 141 tests: d->triggerThreadEvent(); Executed by:
| 54271 | ||||||||||||
327 | - | |||||||||||||
328 | d->m_mainThreadWaiting = true; | - | ||||||||||||
329 | - | |||||||||||||
330 | do { | - | ||||||||||||
331 | if (d->mainSync) {
| 7349-61624 | ||||||||||||
332 | QQmlThread::Message *message = d->mainSync; | - | ||||||||||||
333 | unlock(); | - | ||||||||||||
334 | message->call(this); | - | ||||||||||||
335 | delete message; | - | ||||||||||||
336 | lock(); | - | ||||||||||||
337 | d->mainSync = nullptr; | - | ||||||||||||
338 | wakeOne(); | - | ||||||||||||
339 | } else { executed 7349 times by 133 tests: end of block Executed by:
| 7349 | ||||||||||||
340 | d->wait(); | - | ||||||||||||
341 | } executed 61624 times by 141 tests: end of block Executed by:
| 61624 | ||||||||||||
342 | } while (d->mainSync || !d->threadList.isEmpty());
| 7347-61626 | ||||||||||||
343 | - | |||||||||||||
344 | d->m_mainThreadWaiting = false; | - | ||||||||||||
345 | d->unlock(); | - | ||||||||||||
346 | } executed 54277 times by 141 tests: end of block Executed by:
| 54277 | ||||||||||||
347 | - | |||||||||||||
348 | void QQmlThread::internalCallMethodInMain(Message *message) | - | ||||||||||||
349 | { | - | ||||||||||||
350 | Q_ASSERT(isThisThread()); | - | ||||||||||||
351 | - | |||||||||||||
352 | d->lock(); | - | ||||||||||||
353 | - | |||||||||||||
354 | Q_ASSERT(d->mainSync == nullptr); | - | ||||||||||||
355 | d->mainSync = message; | - | ||||||||||||
356 | - | |||||||||||||
357 | if (d->m_mainThreadWaiting) {
| 42-7347 | ||||||||||||
358 | d->wakeOne(); | - | ||||||||||||
359 | } else if (d->m_mainProcessing) { executed 7347 times by 133 tests: end of block Executed by:
| 0-7347 | ||||||||||||
360 | // Do nothing - it is already looping | - | ||||||||||||
361 | } else { never executed: end of block | 0 | ||||||||||||
362 | d->triggerMainEvent(); | - | ||||||||||||
363 | } executed 42 times by 8 tests: end of block Executed by:
| 42 | ||||||||||||
364 | - | |||||||||||||
365 | while (d->mainSync) {
| 7389 | ||||||||||||
366 | if (d->m_shutdown) {
| 0-7389 | ||||||||||||
367 | delete d->mainSync; | - | ||||||||||||
368 | d->mainSync = nullptr; | - | ||||||||||||
369 | break; never executed: break; | 0 | ||||||||||||
370 | } | - | ||||||||||||
371 | d->wait(); | - | ||||||||||||
372 | } executed 7389 times by 135 tests: end of block Executed by:
| 7389 | ||||||||||||
373 | - | |||||||||||||
374 | d->unlock(); | - | ||||||||||||
375 | } executed 7389 times by 135 tests: end of block Executed by:
| 7389 | ||||||||||||
376 | - | |||||||||||||
377 | void QQmlThread::internalPostMethodToThread(Message *message) | - | ||||||||||||
378 | { | - | ||||||||||||
379 | Q_ASSERT(!isThisThread()); | - | ||||||||||||
380 | d->lock(); | - | ||||||||||||
381 | bool wasEmpty = d->threadList.isEmpty(); | - | ||||||||||||
382 | d->threadList.append(message); | - | ||||||||||||
383 | if (wasEmpty && d->m_threadProcessing == false)
| 0-104 | ||||||||||||
384 | d->triggerThreadEvent(); executed 104 times by 8 tests: d->triggerThreadEvent(); Executed by:
| 104 | ||||||||||||
385 | d->unlock(); | - | ||||||||||||
386 | } executed 110 times by 8 tests: end of block Executed by:
| 110 | ||||||||||||
387 | - | |||||||||||||
388 | void QQmlThread::internalPostMethodToMain(Message *message) | - | ||||||||||||
389 | { | - | ||||||||||||
390 | Q_ASSERT(isThisThread()); | - | ||||||||||||
391 | d->lock(); | - | ||||||||||||
392 | bool wasEmpty = d->mainList.isEmpty(); | - | ||||||||||||
393 | d->mainList.append(message); | - | ||||||||||||
394 | if (wasEmpty && d->m_mainProcessing == false)
| 1-46696 | ||||||||||||
395 | d->triggerMainEvent(); executed 8964 times by 141 tests: d->triggerMainEvent(); Executed by:
| 8964 | ||||||||||||
396 | d->unlock(); | - | ||||||||||||
397 | } executed 55661 times by 141 tests: end of block Executed by:
| 55661 | ||||||||||||
398 | - | |||||||||||||
399 | void QQmlThread::waitForNextMessage() | - | ||||||||||||
400 | { | - | ||||||||||||
401 | Q_ASSERT(!isThisThread()); | - | ||||||||||||
402 | d->lock(); | - | ||||||||||||
403 | Q_ASSERT(d->m_mainThreadWaiting == false); | - | ||||||||||||
404 | - | |||||||||||||
405 | d->m_mainThreadWaiting = true; | - | ||||||||||||
406 | - | |||||||||||||
407 | if (d->mainSync || !d->threadList.isEmpty()) {
| 0-664 | ||||||||||||
408 | if (d->mainSync) {
| 0-4 | ||||||||||||
409 | QQmlThread::Message *message = d->mainSync; | - | ||||||||||||
410 | unlock(); | - | ||||||||||||
411 | message->call(this); | - | ||||||||||||
412 | delete message; | - | ||||||||||||
413 | lock(); | - | ||||||||||||
414 | d->mainSync = nullptr; | - | ||||||||||||
415 | wakeOne(); | - | ||||||||||||
416 | } else { never executed: end of block | 0 | ||||||||||||
417 | d->wait(); | - | ||||||||||||
418 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||
419 | } | - | ||||||||||||
420 | - | |||||||||||||
421 | d->m_mainThreadWaiting = false; | - | ||||||||||||
422 | d->unlock(); | - | ||||||||||||
423 | } executed 664 times by 3 tests: end of block Executed by:
| 664 | ||||||||||||
424 | - | |||||||||||||
425 | - | |||||||||||||
426 | QT_END_NAMESPACE | - | ||||||||||||
Source code | Switch to Preprocessed file |