Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | QStatePrivate::QStatePrivate() | - |
7 | : QAbstractStatePrivate(StandardState), | - |
8 | errorState(0), initialState(0), childMode(QState::ExclusiveStates), | - |
9 | childStatesListNeedsRefresh(true), transitionsListNeedsRefresh(true) | - |
10 | { | - |
11 | } executed: } Execution Count:473 | 473 |
12 | | - |
13 | QStatePrivate::~QStatePrivate() | - |
14 | { | - |
15 | } | - |
16 | | - |
17 | void QStatePrivate::emitFinished() | - |
18 | { | - |
19 | QState * const q = q_func(); | - |
20 | q->finished(QState::QPrivateSignal()); | - |
21 | } executed: } Execution Count:72 | 72 |
22 | | - |
23 | void QStatePrivate::emitPropertiesAssigned() | - |
24 | { | - |
25 | QState * const q = q_func(); | - |
26 | q->propertiesAssigned(QState::QPrivateSignal()); | - |
27 | } executed: } Execution Count:1352 | 1352 |
28 | | - |
29 | | - |
30 | | - |
31 | | - |
32 | QState::QState(QState *parent) | - |
33 | : QAbstractState(*new QStatePrivate, parent) | - |
34 | { | - |
35 | } executed: } Execution Count:334 | 334 |
36 | | - |
37 | | - |
38 | | - |
39 | | - |
40 | | - |
41 | QState::QState(ChildMode childMode, QState *parent) | - |
42 | : QAbstractState(*new QStatePrivate, parent) | - |
43 | { | - |
44 | QStatePrivate * const d = d_func(); | - |
45 | d->childMode = childMode; | - |
46 | } executed: } Execution Count:5 | 5 |
47 | | - |
48 | | - |
49 | | - |
50 | | - |
51 | QState::QState(QStatePrivate &dd, QState *parent) | - |
52 | : QAbstractState(dd, parent) | - |
53 | { | - |
54 | } executed: } Execution Count:134 | 134 |
55 | | - |
56 | | - |
57 | | - |
58 | | - |
59 | QState::~QState() | - |
60 | { | - |
61 | } | - |
62 | | - |
63 | QList<QAbstractState*> QStatePrivate::childStates() const | - |
64 | { | - |
65 | if (childStatesListNeedsRefresh) { evaluated: childStatesListNeedsRefresh yes Evaluation Count:327 | yes Evaluation Count:6162 |
| 327-6162 |
66 | childStatesList.clear(); | - |
67 | QList<QObject*>::const_iterator it; | - |
68 | for (it = children.constBegin(); it != children.constEnd(); ++it) { evaluated: it != children.constEnd() yes Evaluation Count:349 | yes Evaluation Count:327 |
| 327-349 |
69 | QAbstractState *s = qobject_cast<QAbstractState*>(*it); | - |
70 | if (!s || qobject_cast<QHistoryState*>(s)) evaluated: !s yes Evaluation Count:231 | yes Evaluation Count:118 |
evaluated: qobject_cast<QHistoryState*>(s) yes Evaluation Count:5 | yes Evaluation Count:113 |
| 5-231 |
71 | continue; executed: continue; Execution Count:236 | 236 |
72 | childStatesList.append(s); | - |
73 | } executed: } Execution Count:113 | 113 |
74 | childStatesListNeedsRefresh = false; | - |
75 | } executed: } Execution Count:327 | 327 |
76 | return childStatesList; executed: return childStatesList; Execution Count:6489 | 6489 |
77 | } | - |
78 | | - |
79 | QList<QHistoryState*> QStatePrivate::historyStates() const | - |
80 | { | - |
81 | QList<QHistoryState*> result; | - |
82 | QList<QObject*>::const_iterator it; | - |
83 | for (it = children.constBegin(); it != children.constEnd(); ++it) { evaluated: it != children.constEnd() yes Evaluation Count:2405 | yes Evaluation Count:1265 |
| 1265-2405 |
84 | QHistoryState *h = qobject_cast<QHistoryState*>(*it); | - |
85 | if (h) evaluated: h yes Evaluation Count:8 | yes Evaluation Count:2397 |
| 8-2397 |
86 | result.append(h); executed: result.append(h); Execution Count:8 | 8 |
87 | } executed: } Execution Count:2405 | 2405 |
88 | return result; executed: return result; Execution Count:1265 | 1265 |
89 | } | - |
90 | | - |
91 | QList<QAbstractTransition*> QStatePrivate::transitions() const | - |
92 | { | - |
93 | if (transitionsListNeedsRefresh) { evaluated: transitionsListNeedsRefresh yes Evaluation Count:451 | yes Evaluation Count:9447 |
| 451-9447 |
94 | transitionsList.clear(); | - |
95 | QList<QObject*>::const_iterator it; | - |
96 | for (it = children.constBegin(); it != children.constEnd(); ++it) { evaluated: it != children.constEnd() yes Evaluation Count:730 | yes Evaluation Count:451 |
| 451-730 |
97 | QAbstractTransition *t = qobject_cast<QAbstractTransition*>(*it); | - |
98 | if (t) evaluated: t yes Evaluation Count:222 | yes Evaluation Count:508 |
| 222-508 |
99 | transitionsList.append(t); executed: transitionsList.append(t); Execution Count:222 | 222 |
100 | } executed: } Execution Count:730 | 730 |
101 | transitionsListNeedsRefresh = false; | - |
102 | } executed: } Execution Count:451 | 451 |
103 | return transitionsList; executed: return transitionsList; Execution Count:9898 | 9898 |
104 | } | - |
105 | void QState::assignProperty(QObject *object, const char *name, | - |
106 | const QVariant &value) | - |
107 | { | - |
108 | QStatePrivate * const d = d_func(); | - |
109 | if (!object) { evaluated: !object yes Evaluation Count:1 | yes Evaluation Count:103 |
| 1-103 |
110 | QMessageLogger("statemachine/qstate.cpp", 266, __PRETTY_FUNCTION__).warning("QState::assignProperty: cannot assign property '%s' of null object", name); | - |
111 | return; executed: return; Execution Count:1 | 1 |
112 | } | - |
113 | for (int i = 0; i < d->propertyAssignments.size(); ++i) { evaluated: i < d->propertyAssignments.size() yes Evaluation Count:15 | yes Evaluation Count:101 |
| 15-101 |
114 | QPropertyAssignment &assn = d->propertyAssignments[i]; | - |
115 | if (assn.hasTarget(object, name)) { evaluated: assn.hasTarget(object, name) yes Evaluation Count:2 | yes Evaluation Count:13 |
| 2-13 |
116 | assn.value = value; | - |
117 | return; executed: return; Execution Count:2 | 2 |
118 | } | - |
119 | } executed: } Execution Count:13 | 13 |
120 | d->propertyAssignments.append(QPropertyAssignment(object, name, value)); | - |
121 | } executed: } Execution Count:101 | 101 |
122 | QAbstractState *QState::errorState() const | - |
123 | { | - |
124 | const QStatePrivate * const d = d_func(); | - |
125 | return d->errorState; executed: return d->errorState; Execution Count:44 | 44 |
126 | } | - |
127 | void QState::setErrorState(QAbstractState *state) | - |
128 | { | - |
129 | QStatePrivate * const d = d_func(); | - |
130 | if (state != 0 && qobject_cast<QStateMachine*>(state)) { evaluated: state != 0 yes Evaluation Count:14 | yes Evaluation Count:1 |
evaluated: qobject_cast<QStateMachine*>(state) yes Evaluation Count:1 | yes Evaluation Count:13 |
| 1-14 |
131 | QMessageLogger("statemachine/qstate.cpp", 303, __PRETTY_FUNCTION__).warning("QStateMachine::setErrorState: root state cannot be error state"); | - |
132 | return; executed: return; Execution Count:1 | 1 |
133 | } | - |
134 | if (state != 0 && (!state->machine() || ((state->machine() != machine()) && !qobject_cast<QStateMachine*>(this)))) { evaluated: state != 0 yes Evaluation Count:13 | yes Evaluation Count:1 |
evaluated: !state->machine() yes Evaluation Count:1 | yes Evaluation Count:12 |
evaluated: (state->machine() != machine()) yes Evaluation Count:8 | yes Evaluation Count:4 |
evaluated: !qobject_cast<QStateMachine*>(this) yes Evaluation Count:1 | yes Evaluation Count:7 |
| 1-13 |
135 | QMessageLogger("statemachine/qstate.cpp", 307, __PRETTY_FUNCTION__).warning("QState::setErrorState: error state cannot belong " | - |
136 | "to a different state machine"); | - |
137 | return; executed: return; Execution Count:2 | 2 |
138 | } | - |
139 | | - |
140 | d->errorState = state; | - |
141 | } executed: } Execution Count:12 | 12 |
142 | | - |
143 | | - |
144 | | - |
145 | | - |
146 | | - |
147 | void QState::addTransition(QAbstractTransition *transition) | - |
148 | { | - |
149 | QStatePrivate * const d = d_func(); | - |
150 | if (!transition) { evaluated: !transition yes Evaluation Count:1 | yes Evaluation Count:215 |
| 1-215 |
151 | QMessageLogger("statemachine/qstate.cpp", 323, __PRETTY_FUNCTION__).warning("QState::addTransition: cannot add null transition"); | - |
152 | return ; executed: return ; Execution Count:1 | 1 |
153 | } | - |
154 | | - |
155 | transition->setParent(this); | - |
156 | const QList<QPointer<QAbstractState> > &targets = QAbstractTransitionPrivate::get(transition)->targetStates; | - |
157 | for (int i = 0; i < targets.size(); ++i) { evaluated: i < targets.size() yes Evaluation Count:208 | yes Evaluation Count:215 |
| 208-215 |
158 | QAbstractState *t = targets.at(i).data(); | - |
159 | if (!t) { partially evaluated: !t no Evaluation Count:0 | yes Evaluation Count:208 |
| 0-208 |
160 | QMessageLogger("statemachine/qstate.cpp", 332, __PRETTY_FUNCTION__).warning("QState::addTransition: cannot add transition to null state"); | - |
161 | return ; | 0 |
162 | } | - |
163 | if ((QAbstractStatePrivate::get(t)->machine() != d->machine()) evaluated: (QAbstractStatePrivate::get(t)->machine() != d->machine()) yes Evaluation Count:4 | yes Evaluation Count:204 |
| 4-204 |
164 | && QAbstractStatePrivate::get(t)->machine() && d->machine()) { evaluated: QAbstractStatePrivate::get(t)->machine() yes Evaluation Count:1 | yes Evaluation Count:3 |
partially evaluated: d->machine() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-3 |
165 | QMessageLogger("statemachine/qstate.cpp", 337, __PRETTY_FUNCTION__).warning("QState::addTransition: cannot add transition " | - |
166 | "to a state in a different state machine"); | - |
167 | return ; | 0 |
168 | } | - |
169 | } executed: } Execution Count:208 | 208 |
170 | if (QStateMachine *mach = machine()) evaluated: QStateMachine *mach = machine() yes Evaluation Count:207 | yes Evaluation Count:8 |
| 8-207 |
171 | QStateMachinePrivate::get(mach)->maybeRegisterTransition(transition); executed: QStateMachinePrivate::get(mach)->maybeRegisterTransition(transition); Execution Count:207 | 207 |
172 | } executed: } Execution Count:215 | 215 |
173 | | - |
174 | | - |
175 | | - |
176 | | - |
177 | | - |
178 | | - |
179 | QSignalTransition *QState::addTransition(const QObject *sender, const char *signal, | - |
180 | QAbstractState *target) | - |
181 | { | - |
182 | if (!sender) { evaluated: !sender yes Evaluation Count:1 | yes Evaluation Count:51 |
| 1-51 |
183 | QMessageLogger("statemachine/qstate.cpp", 355, __PRETTY_FUNCTION__).warning("QState::addTransition: sender cannot be null"); | - |
184 | return 0; executed: return 0; Execution Count:1 | 1 |
185 | } | - |
186 | if (!signal) { evaluated: !signal yes Evaluation Count:1 | yes Evaluation Count:50 |
| 1-50 |
187 | QMessageLogger("statemachine/qstate.cpp", 359, __PRETTY_FUNCTION__).warning("QState::addTransition: signal cannot be null"); | - |
188 | return 0; executed: return 0; Execution Count:1 | 1 |
189 | } | - |
190 | if (!target) { evaluated: !target yes Evaluation Count:1 | yes Evaluation Count:49 |
| 1-49 |
191 | QMessageLogger("statemachine/qstate.cpp", 363, __PRETTY_FUNCTION__).warning("QState::addTransition: cannot add transition to null state"); | - |
192 | return 0; executed: return 0; Execution Count:1 | 1 |
193 | } | - |
194 | int offset = (*signal == '0'+2) ? 1 : 0; evaluated: (*signal == '0'+2) yes Evaluation Count:48 | yes Evaluation Count:1 |
| 1-48 |
195 | const QMetaObject *meta = sender->metaObject(); | - |
196 | if (meta->indexOfSignal(signal+offset) == -1) { evaluated: meta->indexOfSignal(signal+offset) == -1 yes Evaluation Count:1 | yes Evaluation Count:48 |
| 1-48 |
197 | if (meta->indexOfSignal(QMetaObject::normalizedSignature(signal+offset)) == -1) { partially evaluated: meta->indexOfSignal(QMetaObject::normalizedSignature(signal+offset)) == -1 yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
198 | QMessageLogger("statemachine/qstate.cpp", 370, __PRETTY_FUNCTION__).warning("QState::addTransition: no such signal %s::%s", | - |
199 | meta->className(), signal+offset); | - |
200 | return 0; executed: return 0; Execution Count:1 | 1 |
201 | } | - |
202 | } | 0 |
203 | QSignalTransition *trans = new QSignalTransition(sender, signal); | - |
204 | trans->setTargetState(target); | - |
205 | addTransition(trans); | - |
206 | return trans; executed: return trans; Execution Count:48 | 48 |
207 | } | - |
208 | | - |
209 | namespace { | - |
210 | | - |
211 | | - |
212 | class UnconditionalTransition : public QAbstractTransition | - |
213 | { | - |
214 | public: | - |
215 | UnconditionalTransition(QAbstractState *target) | - |
216 | : QAbstractTransition() | - |
217 | { setTargetState(target); } executed: } Execution Count:15 | 15 |
218 | protected: | - |
219 | void onTransition(QEvent *) {} | - |
220 | bool eventTest(QEvent *) { return true; } executed: return true; Execution Count:18 | 18 |
221 | }; | - |
222 | | - |
223 | } | - |
224 | | - |
225 | | - |
226 | | - |
227 | | - |
228 | | - |
229 | QAbstractTransition *QState::addTransition(QAbstractState *target) | - |
230 | { | - |
231 | if (!target) { evaluated: !target yes Evaluation Count:1 | yes Evaluation Count:15 |
| 1-15 |
232 | QMessageLogger("statemachine/qstate.cpp", 404, __PRETTY_FUNCTION__).warning("QState::addTransition: cannot add transition to null state"); | - |
233 | return 0; executed: return 0; Execution Count:1 | 1 |
234 | } | - |
235 | UnconditionalTransition *trans = new UnconditionalTransition(target); | - |
236 | addTransition(trans); | - |
237 | return trans; executed: return trans; Execution Count:15 | 15 |
238 | } | - |
239 | | - |
240 | | - |
241 | | - |
242 | | - |
243 | | - |
244 | | - |
245 | | - |
246 | void QState::removeTransition(QAbstractTransition *transition) | - |
247 | { | - |
248 | QStatePrivate * const d = d_func(); | - |
249 | if (!transition) { evaluated: !transition yes Evaluation Count:1 | yes Evaluation Count:7 |
| 1-7 |
250 | QMessageLogger("statemachine/qstate.cpp", 422, __PRETTY_FUNCTION__).warning("QState::removeTransition: cannot remove null transition"); | - |
251 | return; executed: return; Execution Count:1 | 1 |
252 | } | - |
253 | if (transition->sourceState() != this) { evaluated: transition->sourceState() != this yes Evaluation Count:1 | yes Evaluation Count:6 |
| 1-6 |
254 | QMessageLogger("statemachine/qstate.cpp", 426, __PRETTY_FUNCTION__).warning("QState::removeTransition: transition %p's source state (%p)" | - |
255 | " is different from this state (%p)", | - |
256 | transition, transition->sourceState(), this); | - |
257 | return; executed: return; Execution Count:1 | 1 |
258 | } | - |
259 | QStateMachinePrivate *mach = QStateMachinePrivate::get(d->machine()); | - |
260 | if (mach) evaluated: mach yes Evaluation Count:5 | yes Evaluation Count:1 |
| 1-5 |
261 | mach->unregisterTransition(transition); executed: mach->unregisterTransition(transition); Execution Count:5 | 5 |
262 | transition->setParent(0); | - |
263 | } executed: } Execution Count:6 | 6 |
264 | QList<QAbstractTransition*> QState::transitions() const | - |
265 | { | - |
266 | const QStatePrivate * const d = d_func(); | - |
267 | return d->transitions(); executed: return d->transitions(); Execution Count:13 | 13 |
268 | } | - |
269 | | - |
270 | | - |
271 | | - |
272 | | - |
273 | void QState::onEntry(QEvent *event) | - |
274 | { | - |
275 | (void)event;; | - |
276 | } executed: } Execution Count:349 | 349 |
277 | | - |
278 | | - |
279 | | - |
280 | | - |
281 | void QState::onExit(QEvent *event) | - |
282 | { | - |
283 | (void)event;; | - |
284 | } executed: } Execution Count:251 | 251 |
285 | | - |
286 | | - |
287 | | - |
288 | | - |
289 | QAbstractState *QState::initialState() const | - |
290 | { | - |
291 | const QStatePrivate * const d = d_func(); | - |
292 | return d->initialState; executed: return d->initialState; Execution Count:345 | 345 |
293 | } | - |
294 | | - |
295 | | - |
296 | | - |
297 | | - |
298 | | - |
299 | void QState::setInitialState(QAbstractState *state) | - |
300 | { | - |
301 | QStatePrivate * const d = d_func(); | - |
302 | if (d->childMode == QState::ParallelStates) { evaluated: d->childMode == QState::ParallelStates yes Evaluation Count:1 | yes Evaluation Count:161 |
| 1-161 |
303 | QMessageLogger("statemachine/qstate.cpp", 485, __PRETTY_FUNCTION__).warning("QState::setInitialState: ignoring attempt to set initial state " | - |
304 | "of parallel state group %p", this); | - |
305 | return; executed: return; Execution Count:1 | 1 |
306 | } | - |
307 | if (state && (state->parentState() != this)) { partially evaluated: state yes Evaluation Count:161 | no Evaluation Count:0 |
evaluated: (state->parentState() != this) yes Evaluation Count:1 | yes Evaluation Count:160 |
| 0-161 |
308 | QMessageLogger("statemachine/qstate.cpp", 490, __PRETTY_FUNCTION__).warning("QState::setInitialState: state %p is not a child of this state (%p)", | - |
309 | state, this); | - |
310 | return; executed: return; Execution Count:1 | 1 |
311 | } | - |
312 | d->initialState = state; | - |
313 | } executed: } Execution Count:160 | 160 |
314 | | - |
315 | | - |
316 | | - |
317 | | - |
318 | QState::ChildMode QState::childMode() const | - |
319 | { | - |
320 | const QStatePrivate * const d = d_func(); | - |
321 | return d->childMode; executed: return d->childMode; Execution Count:365 | 365 |
322 | } | - |
323 | | - |
324 | | - |
325 | | - |
326 | | - |
327 | void QState::setChildMode(ChildMode mode) | - |
328 | { | - |
329 | QStatePrivate * const d = d_func(); | - |
330 | d->childMode = mode; | - |
331 | } executed: } Execution Count:5 | 5 |
332 | | - |
333 | | - |
334 | | - |
335 | | - |
336 | bool QState::event(QEvent *e) | - |
337 | { | - |
338 | QStatePrivate * const d = d_func(); | - |
339 | if ((e->type() == QEvent::ChildAdded) || (e->type() == QEvent::ChildRemoved)) { evaluated: (e->type() == QEvent::ChildAdded) yes Evaluation Count:703 | yes Evaluation Count:295 |
evaluated: (e->type() == QEvent::ChildRemoved) yes Evaluation Count:13 | yes Evaluation Count:282 |
| 13-703 |
340 | d->childStatesListNeedsRefresh = true; | - |
341 | d->transitionsListNeedsRefresh = true; | - |
342 | if ((e->type() == QEvent::ChildRemoved) && (static_cast<QChildEvent *>(e)->child() == d->initialState)) evaluated: (static_cast<QChildEvent *>(e)->child() == d->initialState) yes Evaluation Count:1 | yes Evaluation Count:12 |
evaluated: (e->type() == QEvent::ChildRemoved) yes Evaluation Count:13 | yes Evaluation Count:703 |
| 1-703 |
343 | d->initialState = 0; executed: d->initialState = 0; Execution Count:1 | 1 |
344 | } executed: } Execution Count:716 | 716 |
345 | return QAbstractState::event(e); executed: return QAbstractState::event(e); Execution Count:998 | 998 |
346 | } | - |
347 | | - |
348 | | - |
| | |