OpenCoverage

qfuturewatcher.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/thread/qfuturewatcher.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7QFutureWatcherBase::QFutureWatcherBase(QObject *parent)-
8 :QObject(*new QFutureWatcherBasePrivate, parent)-
9{ }
executed 23 times by 1 test: end of block
Executed by:
  • tst_QFutureWatcher
23
10void QFutureWatcherBase::cancel()-
11{-
12 futureInterface().cancel();-
13}
executed 5 times by 1 test: end of block
Executed by:
  • tst_QFutureWatcher
5
14void QFutureWatcherBase::setPaused(bool paused)-
15{-
16 futureInterface().setPaused(paused);-
17}
never executed: end of block
0
18void QFutureWatcherBase::pause()-
19{-
20 futureInterface().setPaused(true);-
21}
executed 4 times by 1 test: end of block
Executed by:
  • tst_QFutureWatcher
4
22void QFutureWatcherBase::resume()-
23{-
24 futureInterface().setPaused(false);-
25}
executed 4 times by 1 test: end of block
Executed by:
  • tst_QFutureWatcher
4
26void QFutureWatcherBase::togglePaused()-
27{-
28 futureInterface().togglePaused();-
29}
executed 3 times by 1 test: end of block
Executed by:
  • tst_QFutureWatcher
3
30int QFutureWatcherBase::progressValue() const-
31{-
32 return
executed 6 times by 1 test: return futureInterface().progressValue();
Executed by:
  • tst_QFutureWatcher
futureInterface().progressValue();
executed 6 times by 1 test: return futureInterface().progressValue();
Executed by:
  • tst_QFutureWatcher
6
33}-
34-
35-
36-
37-
38-
39-
40-
41int QFutureWatcherBase::progressMinimum() const-
42{-
43 return
executed 6 times by 1 test: return futureInterface().progressMinimum();
Executed by:
  • tst_QFutureWatcher
futureInterface().progressMinimum();
executed 6 times by 1 test: return futureInterface().progressMinimum();
Executed by:
  • tst_QFutureWatcher
6
44}-
45-
46-
47-
48-
49-
50-
51-
52int QFutureWatcherBase::progressMaximum() const-
53{-
54 return
executed 6 times by 1 test: return futureInterface().progressMaximum();
Executed by:
  • tst_QFutureWatcher
futureInterface().progressMaximum();
executed 6 times by 1 test: return futureInterface().progressMaximum();
Executed by:
  • tst_QFutureWatcher
6
55}-
56QString QFutureWatcherBase::progressText() const-
57{-
58 return
executed 6 times by 1 test: return futureInterface().progressText();
Executed by:
  • tst_QFutureWatcher
futureInterface().progressText();
executed 6 times by 1 test: return futureInterface().progressText();
Executed by:
  • tst_QFutureWatcher
6
59}-
60-
61-
62-
63-
64-
65-
66bool QFutureWatcherBase::isStarted() const-
67{-
68 return
executed 7 times by 1 test: return futureInterface().queryState(QFutureInterfaceBase::Started);
Executed by:
  • tst_QFutureWatcher
futureInterface().queryState(QFutureInterfaceBase::Started);
executed 7 times by 1 test: return futureInterface().queryState(QFutureInterfaceBase::Started);
Executed by:
  • tst_QFutureWatcher
7
69}-
70-
71-
72-
73-
74-
75-
76bool QFutureWatcherBase::isFinished() const-
77{-
78 const QFutureWatcherBasePrivate * const d = d_func();-
79 return
executed 11 times by 1 test: return d->finished;
Executed by:
  • tst_QFutureWatcher
d->finished;
executed 11 times by 1 test: return d->finished;
Executed by:
  • tst_QFutureWatcher
11
80}-
81-
82-
83-
84-
85-
86-
87bool QFutureWatcherBase::isRunning() const-
88{-
89 return
executed 6 times by 1 test: return futureInterface().queryState(QFutureInterfaceBase::Running);
Executed by:
  • tst_QFutureWatcher
futureInterface().queryState(QFutureInterfaceBase::Running);
executed 6 times by 1 test: return futureInterface().queryState(QFutureInterfaceBase::Running);
Executed by:
  • tst_QFutureWatcher
6
90}-
91bool QFutureWatcherBase::isCanceled() const-
92{-
93 return
executed 7 times by 1 test: return futureInterface().queryState(QFutureInterfaceBase::Canceled);
Executed by:
  • tst_QFutureWatcher
futureInterface().queryState(QFutureInterfaceBase::Canceled);
executed 7 times by 1 test: return futureInterface().queryState(QFutureInterfaceBase::Canceled);
Executed by:
  • tst_QFutureWatcher
7
94}-
95bool QFutureWatcherBase::isPaused() const-
96{-
97 return
executed 6 times by 1 test: return futureInterface().queryState(QFutureInterfaceBase::Paused);
Executed by:
  • tst_QFutureWatcher
futureInterface().queryState(QFutureInterfaceBase::Paused);
executed 6 times by 1 test: return futureInterface().queryState(QFutureInterfaceBase::Paused);
Executed by:
  • tst_QFutureWatcher
6
98}-
99-
100-
101-
102-
103-
104-
105void QFutureWatcherBase::waitForFinished()-
106{-
107 futureInterface().waitForFinished();-
108}
executed 4 times by 1 test: end of block
Executed by:
  • tst_QFutureWatcher
4
109-
110bool QFutureWatcherBase::event(QEvent *event)-
111{-
112 QFutureWatcherBasePrivate * const d = d_func();-
113 if (event->type() == QEvent::FutureCallOut
event->type() ...:FutureCallOutDescription
TRUEevaluated 1288 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
FALSEnever evaluated
) {
0-1288
114 QFutureCallOutEvent *callOutEvent = static_cast<QFutureCallOutEvent *>(event);-
115-
116 if (futureInterface().isPaused()
futureInterface().isPaused()Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
FALSEevaluated 1281 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
) {
7-1281
117 d->pendingCallOutEvents.append(callOutEvent->clone());-
118 return
executed 7 times by 1 test: return true;
Executed by:
  • tst_QFutureWatcher
true;
executed 7 times by 1 test: return true;
Executed by:
  • tst_QFutureWatcher
7
119 }-
120-
121 if (callOutEvent->callOutType == QFutureCallOutEvent::Resumed
callOutEvent->...Event::ResumedDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QFutureWatcher
FALSEevaluated 1280 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
1-1280
122 && !d->pendingCallOutEvents.isEmpty()
!d->pendingCal...ents.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QFutureWatcher
FALSEnever evaluated
) {
0-1
123-
124 d->sendCallOutEvent(callOutEvent);-
125-
126-
127 for (int i = 0; i < d->pendingCallOutEvents.count()
i < d->pending...Events.count()Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QFutureWatcher
; ++i)
1-7
128 d->sendCallOutEvent(d->pendingCallOutEvents.at(i));
executed 7 times by 1 test: d->sendCallOutEvent(d->pendingCallOutEvents.at(i));
Executed by:
  • tst_QFutureWatcher
7
129 qDeleteAll(d->pendingCallOutEvents);-
130 d->pendingCallOutEvents.clear();-
131 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QFutureWatcher
else {
1
132 d->sendCallOutEvent(callOutEvent);-
133 }
executed 1280 times by 1 test: end of block
Executed by:
  • tst_QFutureWatcher
1280
134 return
executed 1281 times by 1 test: return true;
Executed by:
  • tst_QFutureWatcher
true;
executed 1281 times by 1 test: return true;
Executed by:
  • tst_QFutureWatcher
1281
135 }-
136 return
never executed: return QObject::event(event);
QObject::event(event);
never executed: return QObject::event(event);
0
137}-
138void QFutureWatcherBase::setPendingResultsLimit(int limit)-
139{-
140 QFutureWatcherBasePrivate * const d = d_func();-
141 d->maximumPendingResultsReady = limit;-
142}
never executed: end of block
0
143-
144void QFutureWatcherBase::connectNotify(const QMetaMethod &signal)-
145{-
146 QFutureWatcherBasePrivate * const d = d_func();-
147 static const QMetaMethod resultReadyAtSignal = QMetaMethod::fromSignal(&QFutureWatcherBase::resultReadyAt);-
148 if (signal == resultReadyAtSignal
signal == resultReadyAtSignalDescription
TRUEevaluated 19 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
FALSEevaluated 23 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
)
19-23
149 d->resultAtConnected.ref();
executed 19 times by 1 test: d->resultAtConnected.ref();
Executed by:
  • tst_QFutureWatcher
19
150-
151 static const QMetaMethod finishedSignal = QMetaMethod::fromSignal(&QFutureWatcherBase::finished);-
152 if (signal == finishedSignal
signal == finishedSignalDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
FALSEevaluated 31 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
) {
11-31
153 if (futureInterface().isRunning()
futureInterface().isRunning()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QFutureWatcher
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
) {
1-10
154-
155-
156 QMessageLogger(__FILE__, 368, __PRETTY_FUNCTION__).warning("QFutureWatcher::connect: connecting after calling setFuture() is likely to produce race");-
157 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QFutureWatcher
1
158 }
executed 11 times by 1 test: end of block
Executed by:
  • tst_QFutureWatcher
11
159-
160}
executed 42 times by 1 test: end of block
Executed by:
  • tst_QFutureWatcher
42
161-
162void QFutureWatcherBase::disconnectNotify(const QMetaMethod &signal)-
163{-
164 QFutureWatcherBasePrivate * const d = d_func();-
165 static const QMetaMethod resultReadyAtSignal = QMetaMethod::fromSignal(&QFutureWatcherBase::resultReadyAt);-
166 if (signal == resultReadyAtSignal
signal == resultReadyAtSignalDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
FALSEevaluated 15 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
)
15-16
167 d->resultAtConnected.deref();
executed 16 times by 1 test: d->resultAtConnected.deref();
Executed by:
  • tst_QFutureWatcher
16
168}
executed 31 times by 1 test: end of block
Executed by:
  • tst_QFutureWatcher
31
169-
170-
171-
172-
173QFutureWatcherBasePrivate::QFutureWatcherBasePrivate()-
174 : maximumPendingResultsReady(QThread::idealThreadCount() * 2),-
175 resultAtConnected(0),-
176 finished(true)-
177{ }
executed 23 times by 1 test: end of block
Executed by:
  • tst_QFutureWatcher
23
178-
179-
180-
181-
182void QFutureWatcherBase::connectOutputInterface()-
183{-
184 futureInterface().d->connectOutputInterface(d_func());-
185}
executed 28 times by 1 test: end of block
Executed by:
  • tst_QFutureWatcher
28
186-
187-
188-
189-
190void QFutureWatcherBase::disconnectOutputInterface(bool pendingAssignment)-
191{-
192 if (pendingAssignment
pendingAssignmentDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
FALSEevaluated 23 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
) {
23-28
193 QFutureWatcherBasePrivate * const d = d_func();-
194 d->pendingResultsReady.store(0);-
195 qDeleteAll(d->pendingCallOutEvents);-
196 d->pendingCallOutEvents.clear();-
197 d->finished = false;-
198 }
executed 28 times by 1 test: end of block
Executed by:
  • tst_QFutureWatcher
28
199-
200 futureInterface().d->disconnectOutputInterface(d_func());-
201}
executed 51 times by 1 test: end of block
Executed by:
  • tst_QFutureWatcher
51
202-
203void QFutureWatcherBasePrivate::postCallOutEvent(const QFutureCallOutEvent &callOutEvent)-
204{-
205 QFutureWatcherBase * const q = q_func();-
206-
207 if (callOutEvent.callOutType == QFutureCallOutEvent::ResultsReady
callOutEvent.c...::ResultsReadyDescription
TRUEevaluated 1185 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
FALSEevaluated 160 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
) {
160-1185
208 if (pendingResultsReady.fetchAndAddRelaxed(1) >= maximumPendingResultsReady
pendingResults...ngResultsReadyDescription
TRUEevaluated 1164 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
FALSEevaluated 21 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
)
21-1164
209 q->futureInterface().d->internal_setThrottled(true);
executed 1164 times by 1 test: q->futureInterface().d->internal_setThrottled(true);
Executed by:
  • tst_QFutureWatcher
1164
210 }
executed 1185 times by 1 test: end of block
Executed by:
  • tst_QFutureWatcher
1185
211-
212 QCoreApplication::postEvent(q, callOutEvent.clone());-
213}
executed 1345 times by 1 test: end of block
Executed by:
  • tst_QFutureWatcher
1345
214-
215void QFutureWatcherBasePrivate::callOutInterfaceDisconnected()-
216{-
217 QCoreApplication::removePostedEvents(q_func(), QEvent::FutureCallOut);-
218}
executed 28 times by 1 test: end of block
Executed by:
  • tst_QFutureWatcher
28
219-
220void QFutureWatcherBasePrivate::sendCallOutEvent(QFutureCallOutEvent *event)-
221{-
222 QFutureWatcherBase * const q = q_func();-
223-
224 switch (event->callOutType) {-
225 case
executed 20 times by 1 test: case QFutureCallOutEvent::Started:
Executed by:
  • tst_QFutureWatcher
QFutureCallOutEvent::Started:
executed 20 times by 1 test: case QFutureCallOutEvent::Started:
Executed by:
  • tst_QFutureWatcher
20
226 q->started();-
227 break;
executed 20 times by 1 test: break;
Executed by:
  • tst_QFutureWatcher
20
228 case
executed 17 times by 1 test: case QFutureCallOutEvent::Finished:
Executed by:
  • tst_QFutureWatcher
QFutureCallOutEvent::Finished:
executed 17 times by 1 test: case QFutureCallOutEvent::Finished:
Executed by:
  • tst_QFutureWatcher
17
229 finished = true;-
230 q->finished();-
231 break;
executed 17 times by 1 test: break;
Executed by:
  • tst_QFutureWatcher
17
232 case
executed 5 times by 1 test: case QFutureCallOutEvent::Canceled:
Executed by:
  • tst_QFutureWatcher
QFutureCallOutEvent::Canceled:
executed 5 times by 1 test: case QFutureCallOutEvent::Canceled:
Executed by:
  • tst_QFutureWatcher
5
233 pendingResultsReady.store(0);-
234 q->canceled();-
235 break;
executed 5 times by 1 test: break;
Executed by:
  • tst_QFutureWatcher
5
236 case
executed 1 time by 1 test: case QFutureCallOutEvent::Paused:
Executed by:
  • tst_QFutureWatcher
QFutureCallOutEvent::Paused:
executed 1 time by 1 test: case QFutureCallOutEvent::Paused:
Executed by:
  • tst_QFutureWatcher
1
237 if (q->futureInterface().isCanceled()
q->futureInter...).isCanceled()Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QFutureWatcher
)
0-1
238 break;
never executed: break;
0
239 q->paused();-
240 break;
executed 1 time by 1 test: break;
Executed by:
  • tst_QFutureWatcher
1
241 case
executed 1 time by 1 test: case QFutureCallOutEvent::Resumed:
Executed by:
  • tst_QFutureWatcher
QFutureCallOutEvent::Resumed:
executed 1 time by 1 test: case QFutureCallOutEvent::Resumed:
Executed by:
  • tst_QFutureWatcher
1
242 if (q->futureInterface().isCanceled()
q->futureInter...).isCanceled()Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QFutureWatcher
)
0-1
243 break;
never executed: break;
0
244 q->resumed();-
245 break;
executed 1 time by 1 test: break;
Executed by:
  • tst_QFutureWatcher
1
246 case
executed 1180 times by 1 test: case QFutureCallOutEvent::ResultsReady:
Executed by:
  • tst_QFutureWatcher
QFutureCallOutEvent::ResultsReady:
executed 1180 times by 1 test: case QFutureCallOutEvent::ResultsReady:
Executed by:
  • tst_QFutureWatcher
{
1180
247 if (q->futureInterface().isCanceled()
q->futureInter...).isCanceled()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QFutureWatcher
FALSEevaluated 1179 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
)
1-1179
248 break;
executed 1 time by 1 test: break;
Executed by:
  • tst_QFutureWatcher
1
249-
250 if (pendingResultsReady.fetchAndAddRelaxed(-1) <= maximumPendingResultsReady
pendingResults...ngResultsReadyDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
FALSEevaluated 1164 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
)
15-1164
251 q->futureInterface().setThrottled(false);
executed 15 times by 1 test: q->futureInterface().setThrottled(false);
Executed by:
  • tst_QFutureWatcher
15
252-
253 const int beginIndex = event->index1;-
254 const int endIndex = event->index2;-
255-
256 q->resultsReadyAt(beginIndex, endIndex);-
257-
258 if (resultAtConnected.load() <= 0
resultAtConnected.load() <= 0Description
TRUEevaluated 1001 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
FALSEevaluated 178 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
)
178-1001
259 break;
executed 1001 times by 1 test: break;
Executed by:
  • tst_QFutureWatcher
1001
260-
261 for (int i = beginIndex; i < endIndex
i < endIndexDescription
TRUEevaluated 15008 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
FALSEevaluated 178 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
; ++i)
178-15008
262 q->resultReadyAt(i);
executed 15008 times by 1 test: q->resultReadyAt(i);
Executed by:
  • tst_QFutureWatcher
15008
263-
264 } break;
executed 178 times by 1 test: break;
Executed by:
  • tst_QFutureWatcher
178
265 case
executed 44 times by 1 test: case QFutureCallOutEvent::Progress:
Executed by:
  • tst_QFutureWatcher
QFutureCallOutEvent::Progress:
executed 44 times by 1 test: case QFutureCallOutEvent::Progress:
Executed by:
  • tst_QFutureWatcher
44
266 if (q->futureInterface().isCanceled()
q->futureInter...).isCanceled()Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
FALSEevaluated 39 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
)
5-39
267 break;
executed 5 times by 1 test: break;
Executed by:
  • tst_QFutureWatcher
5
268-
269 q->progressValueChanged(event->index1);-
270 if (!event->text.isNull()
!event->text.isNull()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
FALSEevaluated 35 times by 1 test
Evaluated by:
  • tst_QFutureWatcher
)
4-35
271 q->progressTextChanged(event->text);
executed 4 times by 1 test: q->progressTextChanged(event->text);
Executed by:
  • tst_QFutureWatcher
4
272 break;
executed 39 times by 1 test: break;
Executed by:
  • tst_QFutureWatcher
39
273 case
executed 20 times by 1 test: case QFutureCallOutEvent::ProgressRange:
Executed by:
  • tst_QFutureWatcher
QFutureCallOutEvent::ProgressRange:
executed 20 times by 1 test: case QFutureCallOutEvent::ProgressRange:
Executed by:
  • tst_QFutureWatcher
20
274 q->progressRangeChanged(event->index1, event->index2);-
275 break;
executed 20 times by 1 test: break;
Executed by:
  • tst_QFutureWatcher
20
276 default
never executed: default:
:
never executed: default:
break;
never executed: break;
0
277 }-
278}-
279-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9