Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/statemachine/qstatemachine.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | - | |||||||||||||||||||
5 | - | |||||||||||||||||||
6 | - | |||||||||||||||||||
7 | - | |||||||||||||||||||
8 | - | |||||||||||||||||||
9 | - | |||||||||||||||||||
10 | - | |||||||||||||||||||
11 | - | |||||||||||||||||||
12 | - | |||||||||||||||||||
13 | - | |||||||||||||||||||
14 | - | |||||||||||||||||||
15 | struct CalculationCache { | - | ||||||||||||||||||
16 | struct TransitionInfo { | - | ||||||||||||||||||
17 | QList<QAbstractState*> effectiveTargetStates; | - | ||||||||||||||||||
18 | QSet<QAbstractState*> exitSet; | - | ||||||||||||||||||
19 | QAbstractState *transitionDomain; | - | ||||||||||||||||||
20 | - | |||||||||||||||||||
21 | bool effectiveTargetStatesIsKnown: 1; | - | ||||||||||||||||||
22 | bool exitSetIsKnown : 1; | - | ||||||||||||||||||
23 | bool transitionDomainIsKnown : 1; | - | ||||||||||||||||||
24 | - | |||||||||||||||||||
25 | TransitionInfo() | - | ||||||||||||||||||
26 | : transitionDomain(0) | - | ||||||||||||||||||
27 | , effectiveTargetStatesIsKnown(false) | - | ||||||||||||||||||
28 | , exitSetIsKnown(false) | - | ||||||||||||||||||
29 | , transitionDomainIsKnown(false) | - | ||||||||||||||||||
30 | {} | - | ||||||||||||||||||
31 | }; | - | ||||||||||||||||||
32 | - | |||||||||||||||||||
33 | typedef QHash<QAbstractTransition *, TransitionInfo> TransitionInfoCache; | - | ||||||||||||||||||
34 | TransitionInfoCache cache; | - | ||||||||||||||||||
35 | - | |||||||||||||||||||
36 | bool effectiveTargetStates(QAbstractTransition *t, QList<QAbstractState *> *targets) const | - | ||||||||||||||||||
37 | { | - | ||||||||||||||||||
38 | ((!(targets)) ? qt_assert("targets",__FILE__,205211) : qt_noop()); | - | ||||||||||||||||||
39 | - | |||||||||||||||||||
40 | TransitionInfoCache::const_iterator cacheIt = cache.find(t); | - | ||||||||||||||||||
41 | if (cacheIt == cache.end() || !cacheIt->effectiveTargetStatesIsKnown) | - | ||||||||||||||||||
42 | return false; | - | ||||||||||||||||||
43 | - | |||||||||||||||||||
44 | *targets = cacheIt->effectiveTargetStates; | - | ||||||||||||||||||
45 | return true; | - | ||||||||||||||||||
46 | } | - | ||||||||||||||||||
47 | - | |||||||||||||||||||
48 | void insert(QAbstractTransition *t, const QList<QAbstractState *> &targets) | - | ||||||||||||||||||
49 | { | - | ||||||||||||||||||
50 | TransitionInfoCache::iterator cacheIt = cache.find(t); | - | ||||||||||||||||||
51 | TransitionInfo &ti = cacheIt == cache.end() | - | ||||||||||||||||||
52 | ? *cache.insert(t, TransitionInfo()) | - | ||||||||||||||||||
53 | : *cacheIt; | - | ||||||||||||||||||
54 | - | |||||||||||||||||||
55 | ((!(!ti.effectiveTargetStatesIsKnown)) ? qt_assert("!ti.effectiveTargetStatesIsKnown",__FILE__,222228) : qt_noop()); | - | ||||||||||||||||||
56 | ti.effectiveTargetStates = targets; | - | ||||||||||||||||||
57 | ti.effectiveTargetStatesIsKnown = true; | - | ||||||||||||||||||
58 | } | - | ||||||||||||||||||
59 | - | |||||||||||||||||||
60 | bool exitSet(QAbstractTransition *t, QSet<QAbstractState *> *exits) const | - | ||||||||||||||||||
61 | { | - | ||||||||||||||||||
62 | ((!(exits)) ? qt_assert("exits",__FILE__,229235) : qt_noop()); | - | ||||||||||||||||||
63 | - | |||||||||||||||||||
64 | TransitionInfoCache::const_iterator cacheIt = cache.find(t); | - | ||||||||||||||||||
65 | if (cacheIt == cache.end() || !cacheIt->exitSetIsKnown) | - | ||||||||||||||||||
66 | return false; | - | ||||||||||||||||||
67 | - | |||||||||||||||||||
68 | *exits = cacheIt->exitSet; | - | ||||||||||||||||||
69 | return true; | - | ||||||||||||||||||
70 | } | - | ||||||||||||||||||
71 | - | |||||||||||||||||||
72 | void insert(QAbstractTransition *t, const QSet<QAbstractState *> &exits) | - | ||||||||||||||||||
73 | { | - | ||||||||||||||||||
74 | TransitionInfoCache::iterator cacheIt = cache.find(t); | - | ||||||||||||||||||
75 | TransitionInfo &ti = cacheIt == cache.end() | - | ||||||||||||||||||
76 | ? *cache.insert(t, TransitionInfo()) | - | ||||||||||||||||||
77 | : *cacheIt; | - | ||||||||||||||||||
78 | - | |||||||||||||||||||
79 | ((!(!ti.exitSetIsKnown)) ? qt_assert("!ti.exitSetIsKnown",__FILE__,246252) : qt_noop()); | - | ||||||||||||||||||
80 | ti.exitSet = exits; | - | ||||||||||||||||||
81 | ti.exitSetIsKnown = true; | - | ||||||||||||||||||
82 | } | - | ||||||||||||||||||
83 | - | |||||||||||||||||||
84 | bool transitionDomain(QAbstractTransition *t, QAbstractState **domain) const | - | ||||||||||||||||||
85 | { | - | ||||||||||||||||||
86 | ((!(domain)) ? qt_assert("domain",__FILE__,253259) : qt_noop()); | - | ||||||||||||||||||
87 | - | |||||||||||||||||||
88 | TransitionInfoCache::const_iterator cacheIt = cache.find(t); | - | ||||||||||||||||||
89 | if (cacheIt == cache.end() || !cacheIt->transitionDomainIsKnown) | - | ||||||||||||||||||
90 | return false; | - | ||||||||||||||||||
91 | - | |||||||||||||||||||
92 | *domain = cacheIt->transitionDomain; | - | ||||||||||||||||||
93 | return true; | - | ||||||||||||||||||
94 | } | - | ||||||||||||||||||
95 | - | |||||||||||||||||||
96 | void insert(QAbstractTransition *t, QAbstractState *domain) | - | ||||||||||||||||||
97 | { | - | ||||||||||||||||||
98 | TransitionInfoCache::iterator cacheIt = cache.find(t); | - | ||||||||||||||||||
99 | TransitionInfo &ti = cacheIt == cache.end() | - | ||||||||||||||||||
100 | ? *cache.insert(t, TransitionInfo()) | - | ||||||||||||||||||
101 | : *cacheIt; | - | ||||||||||||||||||
102 | - | |||||||||||||||||||
103 | ((!(!ti.transitionDomainIsKnown)) ? qt_assert("!ti.transitionDomainIsKnown",__FILE__,270276) : qt_noop()); | - | ||||||||||||||||||
104 | ti.transitionDomain = domain; | - | ||||||||||||||||||
105 | ti.transitionDomainIsKnown = true; | - | ||||||||||||||||||
106 | } | - | ||||||||||||||||||
107 | }; | - | ||||||||||||||||||
108 | static inline bool isDescendant(const QAbstractState *state1, const QAbstractState *state2) | - | ||||||||||||||||||
109 | { | - | ||||||||||||||||||
110 | ((!(state1 != 0)) ? qt_assert("state1 != 0",__FILE__,285291) : qt_noop()); | - | ||||||||||||||||||
111 | - | |||||||||||||||||||
112 | for (QAbstractState *it = state1->parentState(); it != 0; it = it->parentState()) { | - | ||||||||||||||||||
113 | if (it == state2) | - | ||||||||||||||||||
114 | return true; | - | ||||||||||||||||||
115 | } | - | ||||||||||||||||||
116 | - | |||||||||||||||||||
117 | return false; | - | ||||||||||||||||||
118 | } | - | ||||||||||||||||||
119 | - | |||||||||||||||||||
120 | static bool containsDecendantOf(const QSet<QAbstractState *> &states, const QAbstractState *node) | - | ||||||||||||||||||
121 | { | - | ||||||||||||||||||
122 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(states)>::type> _container_((states)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QAbstractState *s = *_container_.i; _container_.control; _container_.control = 0: states) | - | ||||||||||||||||||
123 | if (isDescendant(s, node)
| 36-354 | ||||||||||||||||||
124 | return executed 36 times by 1 test: true;return true; Executed by:
executed 36 times by 1 test: return true; Executed by:
| 36 | ||||||||||||||||||
125 | - | |||||||||||||||||||
126 | return executed 56 times by 1 test: false;return false; Executed by:
executed 56 times by 1 test: return false; Executed by:
| 56 | ||||||||||||||||||
127 | } | - | ||||||||||||||||||
128 | - | |||||||||||||||||||
129 | static int descendantDepth(const QAbstractState *state, const QAbstractState *ancestor) | - | ||||||||||||||||||
130 | { | - | ||||||||||||||||||
131 | int depth = 0; | - | ||||||||||||||||||
132 | for (const QAbstractState *it = state; it != 0; it = it->parentState()) { | - | ||||||||||||||||||
133 | if (it == ancestor) | - | ||||||||||||||||||
134 | break; | - | ||||||||||||||||||
135 | ++depth; | - | ||||||||||||||||||
136 | } | - | ||||||||||||||||||
137 | return depth; | - | ||||||||||||||||||
138 | } | - | ||||||||||||||||||
139 | static QVector<QState*> getProperAncestors(const QAbstractState *state, const QAbstractState *upperBound) | - | ||||||||||||||||||
140 | { | - | ||||||||||||||||||
141 | ((!(state != 0)) ? qt_assert("state != 0",__FILE__,328334) : qt_noop()); | - | ||||||||||||||||||
142 | QVector<QState*> result; | - | ||||||||||||||||||
143 | result.reserve(16); | - | ||||||||||||||||||
144 | for (QState *it = state->parentState(); it && it != upperBound; it = it->parentState()) { | - | ||||||||||||||||||
145 | result.append(it); | - | ||||||||||||||||||
146 | } | - | ||||||||||||||||||
147 | return result; | - | ||||||||||||||||||
148 | } | - | ||||||||||||||||||
149 | static QList<QAbstractState *> getEffectiveTargetStates(QAbstractTransition *transition, CalculationCache *cache) | - | ||||||||||||||||||
150 | { | - | ||||||||||||||||||
151 | ((!(cache)) ? qt_assert("cache",__FILE__,357363) : qt_noop()); | - | ||||||||||||||||||
152 | - | |||||||||||||||||||
153 | QList<QAbstractState *> targetsList; | - | ||||||||||||||||||
154 | if (cache->effectiveTargetStates(transition, &targetsList)
| 1237-1394 | ||||||||||||||||||
155 | return executed 1237 times by 2 tests: targetsList;return targetsList; Executed by:
executed 1237 times by 2 tests: return targetsList; Executed by:
| 1237 | ||||||||||||||||||
156 | - | |||||||||||||||||||
157 | QSet<QAbstractState *> targets; | - | ||||||||||||||||||
158 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(transition->const auto targetStates ())>::type> _container_((= transition->targetStates())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)(); | - | ||||||||||||||||||
159 | for (QAbstractState *s = *_container_.i; _container_.control; _container_.control = 0: targetStates) { | - | ||||||||||||||||||
160 | if (QHistoryState *historyState = QStateMachinePrivate::toHistoryState(s)
| 9-1381 | ||||||||||||||||||
161 | QList<QAbstractState*> historyConfiguration = QHistoryStatePrivate::get(historyState)->configuration; | - | ||||||||||||||||||
162 | if (!historyConfiguration.isEmpty()
| 4-5 | ||||||||||||||||||
163 | - | |||||||||||||||||||
164 | targets.unite(historyConfiguration.toSet()); | - | ||||||||||||||||||
165 | } executed 5 times by 1 test: else if (QAbstractTransition *defaultTransition = historyState->defaultTransition()end of block Executed by:
| 1-5 | ||||||||||||||||||
166 | - | |||||||||||||||||||
167 | targets.unite(defaultTransition->targetStates().toSet()); | - | ||||||||||||||||||
168 | } executed 3 times by 1 test: else {end of block Executed by:
| 3 | ||||||||||||||||||
169 | - | |||||||||||||||||||
170 | QStateMachinePrivate *m = QStateMachinePrivate::get(historyState->machine()); | - | ||||||||||||||||||
171 | m->setError(QStateMachine::NoDefaultStateInHistoryStateError, historyState); | - | ||||||||||||||||||
172 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||
173 | } else { | - | ||||||||||||||||||
174 | targets.insert(s); | - | ||||||||||||||||||
175 | } executed 1381 times by 2 tests: end of block Executed by:
| 1381 | ||||||||||||||||||
176 | } | - | ||||||||||||||||||
177 | - | |||||||||||||||||||
178 | targetsList = targets.toList(); | - | ||||||||||||||||||
179 | cache->insert(transition, targetsList); | - | ||||||||||||||||||
180 | return executed 1394 times by 2 tests: targetsList;return targetsList; Executed by:
executed 1394 times by 2 tests: return targetsList; Executed by:
| 1394 | ||||||||||||||||||
181 | } | - | ||||||||||||||||||
182 | - | |||||||||||||||||||
183 | QStateMachinePrivate::QStateMachinePrivate() | - | ||||||||||||||||||
184 | { | - | ||||||||||||||||||
185 | isMachine = true; | - | ||||||||||||||||||
186 | - | |||||||||||||||||||
187 | state = NotRunning; | - | ||||||||||||||||||
188 | processing = false; | - | ||||||||||||||||||
189 | processingScheduled = false; | - | ||||||||||||||||||
190 | stop = false; | - | ||||||||||||||||||
191 | stopProcessingReason = EventQueueEmpty; | - | ||||||||||||||||||
192 | error = QStateMachine::NoError; | - | ||||||||||||||||||
193 | globalRestorePolicy = QState::DontRestoreProperties; | - | ||||||||||||||||||
194 | signalEventGenerator = 0; | - | ||||||||||||||||||
195 | - | |||||||||||||||||||
196 | animated = true; | - | ||||||||||||||||||
197 | - | |||||||||||||||||||
198 | } | - | ||||||||||||||||||
199 | - | |||||||||||||||||||
200 | QStateMachinePrivate::~QStateMachinePrivate() | - | ||||||||||||||||||
201 | { | - | ||||||||||||||||||
202 | qDeleteAll(internalEventQueue); | - | ||||||||||||||||||
203 | qDeleteAll(externalEventQueue); | - | ||||||||||||||||||
204 | - | |||||||||||||||||||
205 | for (QHash<int, DelayedEvent>::const_iterator it = delayedEvents.begin(), eit = delayedEvents.end(); it != eit; ++it) { | - | ||||||||||||||||||
206 | delete it.value().event; | - | ||||||||||||||||||
207 | } | - | ||||||||||||||||||
208 | } | - | ||||||||||||||||||
209 | - | |||||||||||||||||||
210 | QState *QStateMachinePrivate::rootState() const | - | ||||||||||||||||||
211 | { | - | ||||||||||||||||||
212 | return const_cast<QStateMachine*>(q_func()); | - | ||||||||||||||||||
213 | } | - | ||||||||||||||||||
214 | - | |||||||||||||||||||
215 | static QEvent *cloneEvent(QEvent *e) | - | ||||||||||||||||||
216 | { | - | ||||||||||||||||||
217 | switch (e->type()) { | - | ||||||||||||||||||
218 | case QEvent::None: | - | ||||||||||||||||||
219 | return new QEvent(*e); | - | ||||||||||||||||||
220 | case QEvent::Timer: | - | ||||||||||||||||||
221 | return new QTimerEvent(*static_cast<QTimerEvent*>(e)); | - | ||||||||||||||||||
222 | default: | - | ||||||||||||||||||
223 | ((!(false)) ? qt_assert_x("cloneEvent()", "not implemented",__FILE__,428435) : qt_noop()); | - | ||||||||||||||||||
224 | break; | - | ||||||||||||||||||
225 | } | - | ||||||||||||||||||
226 | return 0; | - | ||||||||||||||||||
227 | } | - | ||||||||||||||||||
228 | - | |||||||||||||||||||
229 | const QStateMachinePrivate::Handler qt_kernel_statemachine_handler = { | - | ||||||||||||||||||
230 | cloneEvent | - | ||||||||||||||||||
231 | }; | - | ||||||||||||||||||
232 | - | |||||||||||||||||||
233 | const QStateMachinePrivate::Handler *QStateMachinePrivate::handler = &qt_kernel_statemachine_handler; | - | ||||||||||||||||||
234 | - | |||||||||||||||||||
235 | __attribute__((visibility("default"))) const QStateMachinePrivate::Handler *qcoreStateMachineHandler() | - | ||||||||||||||||||
236 | { | - | ||||||||||||||||||
237 | return &qt_kernel_statemachine_handler; | - | ||||||||||||||||||
238 | } | - | ||||||||||||||||||
239 | - | |||||||||||||||||||
240 | static int indexOfDescendant(QState *s, QAbstractState *desc) | - | ||||||||||||||||||
241 | { | - | ||||||||||||||||||
242 | QList<QAbstractState*> childStates = QStatePrivate::get(s)->childStates(); | - | ||||||||||||||||||
243 | for (int i = 0; i < childStates.size(); ++i) { | - | ||||||||||||||||||
244 | QAbstractState *c = childStates.at(i); | - | ||||||||||||||||||
245 | if ((c == desc) || isDescendant(desc, c)) { | - | ||||||||||||||||||
246 | return i; | - | ||||||||||||||||||
247 | } | - | ||||||||||||||||||
248 | } | - | ||||||||||||||||||
249 | return -1; | - | ||||||||||||||||||
250 | } | - | ||||||||||||||||||
251 | - | |||||||||||||||||||
252 | bool QStateMachinePrivate::transitionStateEntryLessThan(QAbstractTransition *t1, QAbstractTransition *t2) | - | ||||||||||||||||||
253 | { | - | ||||||||||||||||||
254 | QState *s1 = t1->sourceState(), *s2 = t2->sourceState(); | - | ||||||||||||||||||
255 | if (s1 == s2) { | - | ||||||||||||||||||
256 | QList<QAbstractTransition*> transitions = QStatePrivate::get(s1)->transitions(); | - | ||||||||||||||||||
257 | return transitions.indexOf(t1) < transitions.indexOf(t2); | - | ||||||||||||||||||
258 | } else if (isDescendant(s1, s2)) { | - | ||||||||||||||||||
259 | return true; | - | ||||||||||||||||||
260 | } else if (isDescendant(s2, s1)) { | - | ||||||||||||||||||
261 | return false; | - | ||||||||||||||||||
262 | } else { | - | ||||||||||||||||||
263 | ((!(s1->machine() != 0)) ? qt_assert("s1->machine() != 0",__FILE__,468475) : qt_noop()); | - | ||||||||||||||||||
264 | QStateMachinePrivate *mach = QStateMachinePrivate::get(s1->machine()); | - | ||||||||||||||||||
265 | QState *lca = mach->findLCA(QList<QAbstractState*>() << s1 << s2); | - | ||||||||||||||||||
266 | ((!(lca != 0)) ? qt_assert("lca != 0",__FILE__,471478) : qt_noop()); | - | ||||||||||||||||||
267 | int s1Depth = descendantDepth(s1, lca); | - | ||||||||||||||||||
268 | int s2Depth = descendantDepth(s2, lca); | - | ||||||||||||||||||
269 | if (s1Depth == s2Depth) | - | ||||||||||||||||||
270 | return (indexOfDescendant(lca, s1) < indexOfDescendant(lca, s2)); | - | ||||||||||||||||||
271 | else | - | ||||||||||||||||||
272 | return s1Depth > s2Depth; | - | ||||||||||||||||||
273 | } | - | ||||||||||||||||||
274 | } | - | ||||||||||||||||||
275 | - | |||||||||||||||||||
276 | bool QStateMachinePrivate::stateEntryLessThan(QAbstractState *s1, QAbstractState *s2) | - | ||||||||||||||||||
277 | { | - | ||||||||||||||||||
278 | if (s1->parent() == s2->parent()) { | - | ||||||||||||||||||
279 | return s1->parent()->children().indexOf(s1) | - | ||||||||||||||||||
280 | < s2->parent()->children().indexOf(s2); | - | ||||||||||||||||||
281 | } else if (isDescendant(s1, s2)) { | - | ||||||||||||||||||
282 | return false; | - | ||||||||||||||||||
283 | } else if (isDescendant(s2, s1)) { | - | ||||||||||||||||||
284 | return true; | - | ||||||||||||||||||
285 | } else { | - | ||||||||||||||||||
286 | ((!(s1->machine() != 0)) ? qt_assert("s1->machine() != 0",__FILE__,491498) : qt_noop()); | - | ||||||||||||||||||
287 | QStateMachinePrivate *mach = QStateMachinePrivate::get(s1->machine()); | - | ||||||||||||||||||
288 | QState *lca = mach->findLCA(QList<QAbstractState*>() << s1 << s2); | - | ||||||||||||||||||
289 | ((!(lca != 0)) ? qt_assert("lca != 0",__FILE__,494501) : qt_noop()); | - | ||||||||||||||||||
290 | return (indexOfDescendant(lca, s1) < indexOfDescendant(lca, s2)); | - | ||||||||||||||||||
291 | } | - | ||||||||||||||||||
292 | } | - | ||||||||||||||||||
293 | - | |||||||||||||||||||
294 | bool QStateMachinePrivate::stateExitLessThan(QAbstractState *s1, QAbstractState *s2) | - | ||||||||||||||||||
295 | { | - | ||||||||||||||||||
296 | if (s1->parent() == s2->parent()) { | - | ||||||||||||||||||
297 | return s2->parent()->children().indexOf(s2) | - | ||||||||||||||||||
298 | < s1->parent()->children().indexOf(s1); | - | ||||||||||||||||||
299 | } else if (isDescendant(s1, s2)) { | - | ||||||||||||||||||
300 | return true; | - | ||||||||||||||||||
301 | } else if (isDescendant(s2, s1)) { | - | ||||||||||||||||||
302 | return false; | - | ||||||||||||||||||
303 | } else { | - | ||||||||||||||||||
304 | ((!(s1->machine() != 0)) ? qt_assert("s1->machine() != 0",__FILE__,509516) : qt_noop()); | - | ||||||||||||||||||
305 | QStateMachinePrivate *mach = QStateMachinePrivate::get(s1->machine()); | - | ||||||||||||||||||
306 | QState *lca = mach->findLCA(QList<QAbstractState*>() << s1 << s2); | - | ||||||||||||||||||
307 | ((!(lca != 0)) ? qt_assert("lca != 0",__FILE__,512519) : qt_noop()); | - | ||||||||||||||||||
308 | return (indexOfDescendant(lca, s2) < indexOfDescendant(lca, s1)); | - | ||||||||||||||||||
309 | } | - | ||||||||||||||||||
310 | } | - | ||||||||||||||||||
311 | - | |||||||||||||||||||
312 | QState *QStateMachinePrivate::findLCA(const QList<QAbstractState*> &states, bool onlyCompound) const | - | ||||||||||||||||||
313 | { | - | ||||||||||||||||||
314 | if (states.isEmpty()) | - | ||||||||||||||||||
315 | return 0; | - | ||||||||||||||||||
316 | QVector<QState*> ancestors = getProperAncestors(states.at(0), rootState()->parentState()); | - | ||||||||||||||||||
317 | for (int i = 0; i < ancestors.size(); ++i) { | - | ||||||||||||||||||
318 | QState *anc = ancestors.at(i); | - | ||||||||||||||||||
319 | if (onlyCompound && !isCompound(anc)) | - | ||||||||||||||||||
320 | continue; | - | ||||||||||||||||||
321 | - | |||||||||||||||||||
322 | bool ok = true; | - | ||||||||||||||||||
323 | for (int j = states.size() - 1; (j > 0) && ok; --j) { | - | ||||||||||||||||||
324 | const QAbstractState *s = states.at(j); | - | ||||||||||||||||||
325 | if (!isDescendant(s, anc)) | - | ||||||||||||||||||
326 | ok = false; | - | ||||||||||||||||||
327 | } | - | ||||||||||||||||||
328 | if (ok) | - | ||||||||||||||||||
329 | return anc; | - | ||||||||||||||||||
330 | } | - | ||||||||||||||||||
331 | return 0; | - | ||||||||||||||||||
332 | } | - | ||||||||||||||||||
333 | - | |||||||||||||||||||
334 | QState *QStateMachinePrivate::findLCCA(const QList<QAbstractState*> &states) const | - | ||||||||||||||||||
335 | { | - | ||||||||||||||||||
336 | return findLCA(states, true); | - | ||||||||||||||||||
337 | } | - | ||||||||||||||||||
338 | - | |||||||||||||||||||
339 | QList<QAbstractTransition*> QStateMachinePrivate::selectTransitions(QEvent *event, CalculationCache *cache) | - | ||||||||||||||||||
340 | { | - | ||||||||||||||||||
341 | ((!(cache)) ? qt_assert("cache",__FILE__,546553) : qt_noop()); | - | ||||||||||||||||||
342 | const QStateMachine * const q = q_func(); | - | ||||||||||||||||||
343 | - | |||||||||||||||||||
344 | QVarLengthArray<QAbstractState *> configuration_sorted; | - | ||||||||||||||||||
for (QForeachContainer<typename QtPrivate::remove_reference<decltype(configuration)>::type> _container_((configuration)); _container_.control && _container_.i != _container_.e; | ||||||||||||||||||||
345 | ++_container_.i, _container_.control ^= 1)for (QAbstractState *s = *_container_.i; _container_.control; _container_.control = 0): qAsConst(configuration)) { | - | ||||||||||||||||||
346 | if (isAtomic(s)
| 386-3838 | ||||||||||||||||||
347 | configuration_sorted.append(s); executed 3838 times by 2 tests: configuration_sorted.append(s); Executed by:
| 3838 | ||||||||||||||||||
348 | } executed 4224 times by 2 tests: end of block Executed by:
| 4224 | ||||||||||||||||||
349 | std::sort(configuration_sorted.begin(), configuration_sorted.end(), stateEntryLessThan); | - | ||||||||||||||||||
350 | - | |||||||||||||||||||
351 | QList<QAbstractTransition*> enabledTransitions; | - | ||||||||||||||||||
352 | const_cast<QStateMachine*>(q)->beginSelectTransitions(event); | - | ||||||||||||||||||
353 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(configuration_sorted)>::type> _container_((configuration_sorted)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QAbstractState *state = *_container_.i; _container_.control; _container_.control = 0): qAsConst(configuration_sorted)) { | - | ||||||||||||||||||
354 | QVector<QState*> lst = getProperAncestors(state, nullptr); | - | ||||||||||||||||||
355 | if (QState *grp = toStandardState(state)
| 23-3815 | ||||||||||||||||||
356 | lst.prepend(grp); executed 3815 times by 2 tests: lst.prepend(grp); Executed by:
| 3815 | ||||||||||||||||||
357 | bool found = false; | - | ||||||||||||||||||
358 | for (int j = 0; (
| 1244-8136 | ||||||||||||||||||
359 | QState *s = lst.at(j); | - | ||||||||||||||||||
360 | QList<QAbstractTransition*> transitions = QStatePrivate::get(s)->transitions(); | - | ||||||||||||||||||
361 | for (int k = 0; k < transitions.size()
| 5648-5945 | ||||||||||||||||||
362 | QAbstractTransition *t = transitions.at(k); | - | ||||||||||||||||||
363 | if (QAbstractTransitionPrivate::get(t)->callEventTest(event)
| 1244-4701 | ||||||||||||||||||
364 | - | |||||||||||||||||||
365 | - | |||||||||||||||||||
366 | - | |||||||||||||||||||
367 | enabledTransitions.append(t); | - | ||||||||||||||||||
368 | found = true; | - | ||||||||||||||||||
369 | break; executed 1244 times by 2 tests: break; Executed by:
| 1244 | ||||||||||||||||||
370 | } | - | ||||||||||||||||||
371 | } executed 4701 times by 2 tests: end of block Executed by:
| 4701 | ||||||||||||||||||
372 | } executed 6892 times by 2 tests: end of block Executed by:
| 6892 | ||||||||||||||||||
373 | } executed 3838 times by 2 tests: end of block Executed by:
| 3838 | ||||||||||||||||||
374 | - | |||||||||||||||||||
375 | if (!enabledTransitions.isEmpty()
| 1235-2515 | ||||||||||||||||||
376 | removeConflictingTransitions(enabledTransitions, cache); | - | ||||||||||||||||||
377 | - | |||||||||||||||||||
378 | - | |||||||||||||||||||
379 | - | |||||||||||||||||||
380 | } executed 1235 times by 2 tests: end of block Executed by:
| 1235 | ||||||||||||||||||
381 | const_cast<QStateMachine*>(q)->endSelectTransitions(event); | - | ||||||||||||||||||
382 | return executed 3750 times by 2 tests: enabledTransitions;return enabledTransitions; Executed by:
executed 3750 times by 2 tests: return enabledTransitions; Executed by:
| 3750 | ||||||||||||||||||
383 | } | - | ||||||||||||||||||
384 | void QStateMachinePrivate::removeConflictingTransitions(QList<QAbstractTransition*> &enabledTransitions, CalculationCache *cache) | - | ||||||||||||||||||
385 | { | - | ||||||||||||||||||
386 | ((!(cache)) ? qt_assert("cache",__FILE__,616623) : qt_noop()); | - | ||||||||||||||||||
387 | - | |||||||||||||||||||
388 | if (enabledTransitions.size() < 2
| 6-1229 | ||||||||||||||||||
389 | return; executed 1229 times by 2 tests: return; Executed by:
| 1229 | ||||||||||||||||||
390 | - | |||||||||||||||||||
391 | QList<QAbstractTransition*> filteredTransitions; | - | ||||||||||||||||||
392 | filteredTransitions.reserve(enabledTransitions.size()); | - | ||||||||||||||||||
393 | std::sort(enabledTransitions.begin(), enabledTransitions.end(), transitionStateEntryLessThan); | - | ||||||||||||||||||
394 | - | |||||||||||||||||||
395 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(enabledTransitions)>::type> _container_((enabledTransitions)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QAbstractTransition *t1 = *_container_.i; _container_.control; _container_.control = 0): qAsConst(enabledTransitions)) { | - | ||||||||||||||||||
396 | bool t1Preempted = false; | - | ||||||||||||||||||
397 | const QSet<QAbstractState*> exitSetT1 = computeExitSet_Unordered(t1, cache); | - | ||||||||||||||||||
398 | QList<QAbstractTransition*>::iterator t2It = filteredTransitions.begin(); | - | ||||||||||||||||||
399 | while (t2It != filteredTransitions.end()
| 9-10 | ||||||||||||||||||
400 | QAbstractTransition *t2 = *t2It; | - | ||||||||||||||||||
401 | if (t1 == t2
| 3-7 | ||||||||||||||||||
402 | - | |||||||||||||||||||
403 | - | |||||||||||||||||||
404 | t1Preempted = true; | - | ||||||||||||||||||
405 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||||||||
406 | } | - | ||||||||||||||||||
407 | - | |||||||||||||||||||
408 | QSet<QAbstractState*> exitSetT2 = computeExitSet_Unordered(t2, cache); | - | ||||||||||||||||||
409 | if (!exitSetT1.intersects(exitSetT2)
| 3-4 | ||||||||||||||||||
410 | - | |||||||||||||||||||
411 | ++t2It; | - | ||||||||||||||||||
412 | } executed 4 times by 1 test: else {end of block Executed by:
| 4 | ||||||||||||||||||
413 | - | |||||||||||||||||||
414 | if (isDescendant(t1->sourceState(), t2->sourceState())
| 0-3 | ||||||||||||||||||
415 | - | |||||||||||||||||||
416 | t2It = filteredTransitions.erase(t2It); | - | ||||||||||||||||||
417 | } never executed: else {end of block | 0 | ||||||||||||||||||
418 | - | |||||||||||||||||||
419 | - | |||||||||||||||||||
420 | t1Preempted = true; | - | ||||||||||||||||||
421 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||||||||
422 | } | - | ||||||||||||||||||
423 | } | - | ||||||||||||||||||
424 | } | - | ||||||||||||||||||
425 | if (!t1Preempted
| 6-9 | ||||||||||||||||||
426 | filteredTransitions.append(t1); executed 9 times by 1 test: filteredTransitions.append(t1); Executed by:
| 9 | ||||||||||||||||||
427 | } executed 15 times by 1 test: end of block Executed by:
| 15 | ||||||||||||||||||
428 | - | |||||||||||||||||||
429 | enabledTransitions = filteredTransitions; | - | ||||||||||||||||||
430 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||
431 | - | |||||||||||||||||||
432 | void QStateMachinePrivate::microstep(QEvent *event, const QList<QAbstractTransition*> &enabledTransitions, | - | ||||||||||||||||||
433 | CalculationCache *cache) | - | ||||||||||||||||||
434 | { | - | ||||||||||||||||||
435 | ((!(cache)) ? qt_assert("cache",__FILE__,665672) : qt_noop()); | - | ||||||||||||||||||
436 | - | |||||||||||||||||||
437 | - | |||||||||||||||||||
438 | - | |||||||||||||||||||
439 | - | |||||||||||||||||||
440 | - | |||||||||||||||||||
441 | QList<QAbstractState*> exitedStates = computeExitSet(enabledTransitions, cache); | - | ||||||||||||||||||
442 | QHash<RestorableId, QVariant> pendingRestorables = computePendingRestorables(exitedStates); | - | ||||||||||||||||||
443 | - | |||||||||||||||||||
444 | QSet<QAbstractState*> statesForDefaultEntry; | - | ||||||||||||||||||
445 | QList<QAbstractState*> enteredStates = computeEntrySet(enabledTransitions, statesForDefaultEntry, cache); | - | ||||||||||||||||||
446 | - | |||||||||||||||||||
447 | - | |||||||||||||||||||
448 | - | |||||||||||||||||||
449 | - | |||||||||||||||||||
450 | - | |||||||||||||||||||
451 | - | |||||||||||||||||||
452 | QHash<QAbstractState*, QVector<QPropertyAssignment> > assignmentsForEnteredStates = | - | ||||||||||||||||||
453 | computePropertyAssignments(enteredStates, pendingRestorables); | - | ||||||||||||||||||
454 | if (!pendingRestorables.isEmpty()
| 23-1212 | ||||||||||||||||||
455 | - | |||||||||||||||||||
456 | - | |||||||||||||||||||
457 | ((!(!enteredStates.isEmpty())) ? qt_assert("!enteredStates.isEmpty()",__FILE__,687694) : qt_noop()); | - | ||||||||||||||||||
458 | QAbstractState *s = enteredStates.firstconstFirst(); | - | ||||||||||||||||||
459 | assignmentsForEnteredStates[s] << restorablesToPropertyList(pendingRestorables); | - | ||||||||||||||||||
460 | } executed 23 times by 1 test: end of block Executed by:
| 23 | ||||||||||||||||||
461 | - | |||||||||||||||||||
462 | exitStates(event, exitedStates, assignmentsForEnteredStates); | - | ||||||||||||||||||
463 | - | |||||||||||||||||||
464 | - | |||||||||||||||||||
465 | - | |||||||||||||||||||
466 | - | |||||||||||||||||||
467 | executeTransitionContent(event, enabledTransitions); | - | ||||||||||||||||||
468 | - | |||||||||||||||||||
469 | - | |||||||||||||||||||
470 | QList<QAbstractAnimation *> selectedAnimations = selectAnimations(enabledTransitions); | - | ||||||||||||||||||
471 | - | |||||||||||||||||||
472 | - | |||||||||||||||||||
473 | enterStates(event, exitedStates, enteredStates, statesForDefaultEntry, assignmentsForEnteredStates | - | ||||||||||||||||||
474 | - | |||||||||||||||||||
475 | , selectedAnimations | - | ||||||||||||||||||
476 | - | |||||||||||||||||||
477 | ); | - | ||||||||||||||||||
478 | - | |||||||||||||||||||
479 | - | |||||||||||||||||||
480 | - | |||||||||||||||||||
481 | - | |||||||||||||||||||
482 | } executed 1235 times by 2 tests: end of block Executed by:
| 1235 | ||||||||||||||||||
483 | QList<QAbstractState*> QStateMachinePrivate::computeExitSet(const QList<QAbstractTransition*> &enabledTransitions, | - | ||||||||||||||||||
484 | CalculationCache *cache) | - | ||||||||||||||||||
485 | { | - | ||||||||||||||||||
486 | ((!(cache)) ? qt_assert("cache",__FILE__,737744) : qt_noop()); | - | ||||||||||||||||||
487 | - | |||||||||||||||||||
488 | QList<QAbstractState*> statesToExit_sorted = computeExitSet_Unordered(enabledTransitions, cache).toList(); | - | ||||||||||||||||||
489 | std::sort(statesToExit_sorted.begin(), statesToExit_sorted.end(), stateExitLessThan); | - | ||||||||||||||||||
490 | return statesToExit_sorted; | - | ||||||||||||||||||
491 | } | - | ||||||||||||||||||
492 | - | |||||||||||||||||||
493 | QSet<QAbstractState*> QStateMachinePrivate::computeExitSet_Unordered(const QList<QAbstractTransition*> &enabledTransitions, | - | ||||||||||||||||||
494 | CalculationCache *cache) | - | ||||||||||||||||||
495 | { | - | ||||||||||||||||||
496 | ((!(cache)) ? qt_assert("cache",__FILE__,747754) : qt_noop()); | - | ||||||||||||||||||
497 | - | |||||||||||||||||||
498 | QSet<QAbstractState*> statesToExit; | - | ||||||||||||||||||
for (QForeachContainer<typename QtPrivate::remove_reference<decltype(enabledTransitions)>::type> _container_((enabledTransitions)); _container_.control && _container_.i != _container_.e; | ||||||||||||||||||||
499 | ++_container_.i, _container_.control ^= 1)for (QAbstractTransition *t = *_container_.i; _container_.control; _container_.control = 0: enabledTransitions) | - | ||||||||||||||||||
500 | statesToExit.unite(computeExitSet_Unordered(t, cache)); executed 1238 times by 2 tests: statesToExit.unite(computeExitSet_Unordered(t, cache)); Executed by:
| 1238 | ||||||||||||||||||
501 | return executed 1235 times by 2 tests: statesToExit;return statesToExit; Executed by:
executed 1235 times by 2 tests: return statesToExit; Executed by:
| 1235 | ||||||||||||||||||
502 | } | - | ||||||||||||||||||
503 | - | |||||||||||||||||||
504 | QSet<QAbstractState*> QStateMachinePrivate::computeExitSet_Unordered(QAbstractTransition *t, | - | ||||||||||||||||||
505 | CalculationCache *cache) | - | ||||||||||||||||||
506 | { | - | ||||||||||||||||||
507 | ((!(cache)) ? qt_assert("cache",__FILE__,758765) : qt_noop()); | - | ||||||||||||||||||
508 | - | |||||||||||||||||||
509 | QSet<QAbstractState*> statesToExit; | - | ||||||||||||||||||
510 | if (cache->exitSet(t, &statesToExit)
| 19-1241 | ||||||||||||||||||
511 | return executed 19 times by 1 test: statesToExit;return statesToExit; Executed by:
executed 19 times by 1 test: return statesToExit; Executed by:
| 19 | ||||||||||||||||||
512 | - | |||||||||||||||||||
513 | QList<QAbstractState *> effectiveTargetStates = getEffectiveTargetStates(t, cache); | - | ||||||||||||||||||
514 | QAbstractState *domain = getTransitionDomain(t, effectiveTargetStates, cache); | - | ||||||||||||||||||
515 | if (domain == nullptr
| 4-1232 | ||||||||||||||||||
516 | - | |||||||||||||||||||
517 | - | |||||||||||||||||||
518 | - | |||||||||||||||||||
519 | - | |||||||||||||||||||
520 | - | |||||||||||||||||||
521 | - | |||||||||||||||||||
522 | - | |||||||||||||||||||
523 | if (error == QStateMachine::NoError
| 1-3 | ||||||||||||||||||
524 | setError(QStateMachine::NoCommonAncestorForTransitionError, t->sourceState()); executed 3 times by 1 test: setError(QStateMachine::NoCommonAncestorForTransitionError, t->sourceState()); Executed by:
| 3 | ||||||||||||||||||
525 | QList<QAbstractState *> lst = pendingErrorStates.toList(); | - | ||||||||||||||||||
526 | lst.prepend(t->sourceState()); | - | ||||||||||||||||||
527 | - | |||||||||||||||||||
528 | domain = findLCCA(lst); | - | ||||||||||||||||||
529 | ((!(domain != 0)) ? qt_assert("domain != 0",__FILE__,780787) : qt_noop()); | - | ||||||||||||||||||
530 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
531 | - | |||||||||||||||||||
532 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(configuration)>::type> _container_((configuration)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QAbstractState* s = *_container_.i; _container_.control; _container_.control = 0): qAsConst(configuration)) { | - | ||||||||||||||||||
533 | if (isDescendant(s, domain)
| 104-1315 | ||||||||||||||||||
534 | statesToExit.insert(s); executed 1315 times by 2 tests: statesToExit.insert(s); Executed by:
| 1315 | ||||||||||||||||||
535 | } executed 1419 times by 2 tests: end of block Executed by:
| 1419 | ||||||||||||||||||
536 | - | |||||||||||||||||||
537 | cache->insert(t, statesToExit); | - | ||||||||||||||||||
538 | return executed 1241 times by 2 tests: statesToExit;return statesToExit; Executed by:
executed 1241 times by 2 tests: return statesToExit; Executed by:
| 1241 | ||||||||||||||||||
539 | } | - | ||||||||||||||||||
540 | - | |||||||||||||||||||
541 | void QStateMachinePrivate::exitStates(QEvent *event, const QList<QAbstractState*> &statesToExit_sorted, | - | ||||||||||||||||||
542 | const QHash<QAbstractState*, QVector<QPropertyAssignment> > &assignmentsForEnteredStates) | - | ||||||||||||||||||
543 | { | - | ||||||||||||||||||
544 | for (int i = 0; i < statesToExit_sorted.size(); ++i) { | - | ||||||||||||||||||
545 | QAbstractState *s = statesToExit_sorted.at(i); | - | ||||||||||||||||||
546 | if (QState *grp = toStandardState(s)) { | - | ||||||||||||||||||
547 | QList<QHistoryState*> hlst = QStatePrivate::get(grp)->historyStates(); | - | ||||||||||||||||||
548 | for (int j = 0; j < hlst.size(); ++j) { | - | ||||||||||||||||||
549 | QHistoryState *h = hlst.at(j); | - | ||||||||||||||||||
550 | QHistoryStatePrivate::get(h)->configuration.clear(); | - | ||||||||||||||||||
551 | QSet<QAbstractState*>::const_iterator it; | - | ||||||||||||||||||
552 | for (it = configuration.constBegin(); it != configuration.constEnd(); ++it) { | - | ||||||||||||||||||
553 | QAbstractState *s0 = *it; | - | ||||||||||||||||||
554 | if (QHistoryStatePrivate::get(h)->historyType == QHistoryState::DeepHistory) { | - | ||||||||||||||||||
555 | if (isAtomic(s0) && isDescendant(s0, s)) | - | ||||||||||||||||||
556 | QHistoryStatePrivate::get(h)->configuration.append(s0); | - | ||||||||||||||||||
557 | } else if (s0->parentState() == s) { | - | ||||||||||||||||||
558 | QHistoryStatePrivate::get(h)->configuration.append(s0); | - | ||||||||||||||||||
559 | } | - | ||||||||||||||||||
560 | } | - | ||||||||||||||||||
561 | - | |||||||||||||||||||
562 | - | |||||||||||||||||||
563 | - | |||||||||||||||||||
564 | - | |||||||||||||||||||
565 | } | - | ||||||||||||||||||
566 | } | - | ||||||||||||||||||
567 | } | - | ||||||||||||||||||
568 | for (int i = 0; i < statesToExit_sorted.size(); ++i) { | - | ||||||||||||||||||
569 | QAbstractState *s = statesToExit_sorted.at(i); | - | ||||||||||||||||||
570 | - | |||||||||||||||||||
571 | - | |||||||||||||||||||
572 | - | |||||||||||||||||||
573 | QAbstractStatePrivate::get(s)->callOnExit(event); | - | ||||||||||||||||||
574 | - | |||||||||||||||||||
575 | - | |||||||||||||||||||
576 | terminateActiveAnimations(s, assignmentsForEnteredStates); | - | ||||||||||||||||||
577 | - | |||||||||||||||||||
578 | - | |||||||||||||||||||
579 | - | |||||||||||||||||||
580 | - | |||||||||||||||||||
581 | configuration.remove(s); | - | ||||||||||||||||||
582 | QAbstractStatePrivate::get(s)->emitExited(); | - | ||||||||||||||||||
583 | } | - | ||||||||||||||||||
584 | } | - | ||||||||||||||||||
585 | - | |||||||||||||||||||
586 | void QStateMachinePrivate::executeTransitionContent(QEvent *event, const QList<QAbstractTransition*> &enabledTransitions) | - | ||||||||||||||||||
587 | { | - | ||||||||||||||||||
588 | for (int i = 0; i < enabledTransitions.size(); ++i) { | - | ||||||||||||||||||
589 | QAbstractTransition *t = enabledTransitions.at(i); | - | ||||||||||||||||||
590 | - | |||||||||||||||||||
591 | - | |||||||||||||||||||
592 | - | |||||||||||||||||||
593 | QAbstractTransitionPrivate::get(t)->callOnTransition(event); | - | ||||||||||||||||||
594 | QAbstractTransitionPrivate::get(t)->emitTriggered(); | - | ||||||||||||||||||
595 | } | - | ||||||||||||||||||
596 | } | - | ||||||||||||||||||
597 | - | |||||||||||||||||||
598 | QList<QAbstractState*> QStateMachinePrivate::computeEntrySet(const QList<QAbstractTransition *> &enabledTransitions, | - | ||||||||||||||||||
599 | QSet<QAbstractState *> &statesForDefaultEntry, | - | ||||||||||||||||||
600 | CalculationCache *cache) | - | ||||||||||||||||||
601 | { | - | ||||||||||||||||||
602 | ((!(cache)) ? qt_assert("cache",__FILE__,853860) : qt_noop()); | - | ||||||||||||||||||
603 | - | |||||||||||||||||||
604 | QSet<QAbstractState*> statesToEnter; | - | ||||||||||||||||||
605 | if (pendingErrorStates.isEmpty()
| 1-1387 | ||||||||||||||||||
606 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(enabledTransitions)>::type> _container_((enabledTransitions)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QAbstractTransition *t = *_container_.i; _container_.control; _container_.control = 0: enabledTransitions) { | - | ||||||||||||||||||
607 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(t->const auto targetStates ())>::type> _container_((= t->targetStates())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)(); | - | ||||||||||||||||||
608 | for (QAbstractState *s = *_container_.i; _container_.control; _container_.control = 0: targetStates) | - | ||||||||||||||||||
609 | {addDescendantStatesToEnter(s, statesToEnter, statesForDefaultEntry); executed 1386 times by 2 tests: addDescendantStatesToEnter(s, statesToEnter, statesForDefaultEntry); Executed by:
| 1386 | ||||||||||||||||||
610 | - | |||||||||||||||||||
611 | }const QList<QAbstractState *> effectiveTargetStates = getEffectiveTargetStates(t, cache); | - | ||||||||||||||||||
612 | QAbstractState *ancestor = getTransitionDomain(t, effectiveTargetStates, cache); | - | ||||||||||||||||||
613 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(effectiveTargetStates)>::type> _container_((effectiveTargetStates)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QAbstractState *s = *_container_.i; _container_.control; _container_.control = 0: effectiveTargetStates) | - | ||||||||||||||||||
614 | {addAncestorStatesToEnter(s, ancestor, statesToEnter, statesForDefaultEntry); executed 1390 times by 2 tests: addAncestorStatesToEnter(s, ancestor, statesToEnter, statesForDefaultEntry); Executed by:
| 1390 | ||||||||||||||||||
615 | }} executed 1390 times by 2 tests: end of block Executed by:
| 1390 | ||||||||||||||||||
616 | } executed 1387 times by 2 tests: end of block Executed by:
| 1387 | ||||||||||||||||||
617 | - | |||||||||||||||||||
618 | - | |||||||||||||||||||
619 | if (!pendingErrorStates.isEmpty()
| 9-1379 | ||||||||||||||||||
620 | statesToEnter.clear(); | - | ||||||||||||||||||
621 | statesToEnter = pendingErrorStates; | - | ||||||||||||||||||
622 | statesForDefaultEntry = pendingErrorStatesForDefaultEntry; | - | ||||||||||||||||||
623 | pendingErrorStates.clear(); | - | ||||||||||||||||||
624 | pendingErrorStatesForDefaultEntry.clear(); | - | ||||||||||||||||||
625 | } executed 9 times by 1 test: end of block Executed by:
| 9 | ||||||||||||||||||
626 | - | |||||||||||||||||||
627 | QList<QAbstractState*> statesToEnter_sorted = statesToEnter.toList(); | - | ||||||||||||||||||
628 | std::sort(statesToEnter_sorted.begin(), statesToEnter_sorted.end(), stateEntryLessThan); | - | ||||||||||||||||||
629 | return executed 1388 times by 2 tests: statesToEnter_sorted;return statesToEnter_sorted; Executed by:
executed 1388 times by 2 tests: return statesToEnter_sorted; Executed by:
| 1388 | ||||||||||||||||||
630 | } | - | ||||||||||||||||||
631 | QAbstractState *QStateMachinePrivate::getTransitionDomain(QAbstractTransition *t, | - | ||||||||||||||||||
632 | const QList<QAbstractState *> &effectiveTargetStates, | - | ||||||||||||||||||
633 | CalculationCache *cache) const | - | ||||||||||||||||||
634 | { | - | ||||||||||||||||||
635 | ((!(cache)) ? qt_assert("cache",__FILE__,904910) : qt_noop()); | - | ||||||||||||||||||
636 | - | |||||||||||||||||||
637 | if (effectiveTargetStates.isEmpty()
| 11-2620 | ||||||||||||||||||
638 | return executed 11 times by 1 test: 0;return 0; Executed by:
executed 11 times by 1 test: return 0; Executed by:
| 11 | ||||||||||||||||||
639 | - | |||||||||||||||||||
640 | QAbstractState *domain = nullptr; | - | ||||||||||||||||||
641 | if (cache->transitionDomain(t, &domain)
| 1231-1389 | ||||||||||||||||||
642 | return executed 1231 times by 2 tests: domain;return domain; Executed by:
executed 1231 times by 2 tests: return domain; Executed by:
| 1231 | ||||||||||||||||||
643 | - | |||||||||||||||||||
644 | if (t->transitionType() == QAbstractTransition::InternalTransition
| 2-1387 | ||||||||||||||||||
645 | if (QState *tSource = t->sourceState()
| 0-2 | ||||||||||||||||||
646 | if (isCompound(tSource)
| 0-2 | ||||||||||||||||||
647 | bool allDescendants = true; | - | ||||||||||||||||||
for (QForeachContainer<typename QtPrivate::remove_reference<decltype(effectiveTargetStates)>::type> _container_((effectiveTargetStates)); _container_.control && _container_.i != _container_.e; | ||||||||||||||||||||
648 | ++_container_.i, _container_.control ^= 1)for (QAbstractState *s = *_container_.i; _container_.control; _container_.control = 0: effectiveTargetStates) { | - | ||||||||||||||||||
649 | if (!isDescendant(s, tSource)
| 0-2 | ||||||||||||||||||
650 | allDescendants = false; | - | ||||||||||||||||||
651 | break; never executed: break; | 0 | ||||||||||||||||||
652 | } | - | ||||||||||||||||||
653 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
654 | - | |||||||||||||||||||
655 | if (allDescendants
| 0-2 | ||||||||||||||||||
656 | return executed 2 times by 1 test: tSource;return tSource; Executed by:
executed 2 times by 1 test: return tSource; Executed by:
| 2 | ||||||||||||||||||
657 | } never executed: end of block | 0 | ||||||||||||||||||
658 | } never executed: end of block | 0 | ||||||||||||||||||
659 | } never executed: end of block | 0 | ||||||||||||||||||
660 | - | |||||||||||||||||||
661 | QList<QAbstractState *> states(effectiveTargetStates); | - | ||||||||||||||||||
662 | if (QAbstractState *src = t->sourceState()
| 153-1234 | ||||||||||||||||||
663 | states.prepend(src); executed 1234 times by 2 tests: states.prepend(src); Executed by:
| 1234 | ||||||||||||||||||
664 | domain = findLCCA(states); | - | ||||||||||||||||||
665 | cache->insert(t, domain); | - | ||||||||||||||||||
666 | return executed 1387 times by 2 tests: domain;return domain; Executed by:
executed 1387 times by 2 tests: return domain; Executed by:
| 1387 | ||||||||||||||||||
667 | } | - | ||||||||||||||||||
668 | - | |||||||||||||||||||
669 | void QStateMachinePrivate::enterStates(QEvent *event, const QList<QAbstractState*> &exitedStates_sorted, | - | ||||||||||||||||||
670 | const QList<QAbstractState*> &statesToEnter_sorted, | - | ||||||||||||||||||
671 | const QSet<QAbstractState*> &statesForDefaultEntry, | - | ||||||||||||||||||
672 | QHash<QAbstractState*, QVector<QPropertyAssignment> > &propertyAssignmentsForState | - | ||||||||||||||||||
673 | - | |||||||||||||||||||
674 | , const QList<QAbstractAnimation *> &selectedAnimations | - | ||||||||||||||||||
675 | - | |||||||||||||||||||
676 | ) | - | ||||||||||||||||||
677 | { | - | ||||||||||||||||||
678 | - | |||||||||||||||||||
679 | - | |||||||||||||||||||
680 | - | |||||||||||||||||||
681 | for (int i = 0; i < statesToEnter_sorted.size(); ++i) { | - | ||||||||||||||||||
682 | QAbstractState *s = statesToEnter_sorted.at(i); | - | ||||||||||||||||||
683 | - | |||||||||||||||||||
684 | - | |||||||||||||||||||
685 | - | |||||||||||||||||||
686 | configuration.insert(s); | - | ||||||||||||||||||
687 | registerTransitions(s); | - | ||||||||||||||||||
688 | - | |||||||||||||||||||
689 | - | |||||||||||||||||||
690 | initializeAnimations(s, selectedAnimations, exitedStates_sorted, propertyAssignmentsForState); | - | ||||||||||||||||||
691 | - | |||||||||||||||||||
692 | - | |||||||||||||||||||
693 | - | |||||||||||||||||||
694 | { | - | ||||||||||||||||||
695 | QVector<QPropertyAssignment> assignments = propertyAssignmentsForState.value(s); | - | ||||||||||||||||||
696 | for (int i = 0; i < assignments.size(); ++i) { | - | ||||||||||||||||||
697 | const QPropertyAssignment &assn = assignments.at(i); | - | ||||||||||||||||||
698 | if (globalRestorePolicy == QState::RestoreProperties) { | - | ||||||||||||||||||
699 | if (assn.explicitlySet) { | - | ||||||||||||||||||
700 | if (!hasRestorable(s, assn.object, assn.propertyName)) { | - | ||||||||||||||||||
701 | QVariant value = savedValueForRestorable(exitedStates_sorted, assn.object, assn.propertyName); | - | ||||||||||||||||||
702 | unregisterRestorables(exitedStates_sorted, assn.object, assn.propertyName); | - | ||||||||||||||||||
703 | registerRestorable(s, assn.object, assn.propertyName, value); | - | ||||||||||||||||||
704 | } | - | ||||||||||||||||||
705 | } else { | - | ||||||||||||||||||
706 | - | |||||||||||||||||||
707 | - | |||||||||||||||||||
708 | - | |||||||||||||||||||
709 | unregisterRestorables(exitedStates_sorted, assn.object, assn.propertyName); | - | ||||||||||||||||||
710 | } | - | ||||||||||||||||||
711 | } | - | ||||||||||||||||||
712 | assn.write(); | - | ||||||||||||||||||
713 | } | - | ||||||||||||||||||
714 | } | - | ||||||||||||||||||
715 | - | |||||||||||||||||||
716 | QAbstractStatePrivate::get(s)->callOnEntry(event); | - | ||||||||||||||||||
717 | QAbstractStatePrivate::get(s)->emitEntered(); | - | ||||||||||||||||||
718 | - | |||||||||||||||||||
719 | - | |||||||||||||||||||
720 | - | |||||||||||||||||||
721 | - | |||||||||||||||||||
722 | - | |||||||||||||||||||
723 | - | |||||||||||||||||||
724 | (void)statesForDefaultEntry;; | - | ||||||||||||||||||
725 | - | |||||||||||||||||||
726 | if (QHistoryState *h = toHistoryState(s)) | - | ||||||||||||||||||
727 | QAbstractTransitionPrivate::get(h->defaultTransition())->callOnTransition(event); | - | ||||||||||||||||||
728 | - | |||||||||||||||||||
729 | - | |||||||||||||||||||
730 | { | - | ||||||||||||||||||
731 | QState *ss = toStandardState(s); | - | ||||||||||||||||||
732 | if (ss | - | ||||||||||||||||||
733 | - | |||||||||||||||||||
734 | && !animationsForState.contains(s) | - | ||||||||||||||||||
735 | - | |||||||||||||||||||
736 | ) | - | ||||||||||||||||||
737 | QStatePrivate::get(ss)->emitPropertiesAssigned(); | - | ||||||||||||||||||
738 | } | - | ||||||||||||||||||
739 | - | |||||||||||||||||||
740 | if (isFinal(s)) { | - | ||||||||||||||||||
741 | QState *parent = s->parentState(); | - | ||||||||||||||||||
742 | if (parent) { | - | ||||||||||||||||||
743 | if (parent != rootState()) { | - | ||||||||||||||||||
744 | QFinalState *finalState = qobject_cast<QFinalState *>(s); | - | ||||||||||||||||||
745 | ((!(finalState)) ? qt_assert("finalState",__FILE__,10141020) : qt_noop()); | - | ||||||||||||||||||
746 | emitStateFinished(parent, finalState); | - | ||||||||||||||||||
747 | } | - | ||||||||||||||||||
748 | QState *grandparent = parent->parentState(); | - | ||||||||||||||||||
749 | if (grandparent && isParallel(grandparent)) { | - | ||||||||||||||||||
750 | bool allChildStatesFinal = true; | - | ||||||||||||||||||
751 | QList<QAbstractState*> childStates = QStatePrivate::get(grandparent)->childStates(); | - | ||||||||||||||||||
752 | for (int j = 0; j < childStates.size(); ++j) { | - | ||||||||||||||||||
753 | QAbstractState *cs = childStates.at(j); | - | ||||||||||||||||||
754 | if (!isInFinalState(cs)) { | - | ||||||||||||||||||
755 | allChildStatesFinal = false; | - | ||||||||||||||||||
756 | break; | - | ||||||||||||||||||
757 | } | - | ||||||||||||||||||
758 | } | - | ||||||||||||||||||
759 | if (allChildStatesFinal && (grandparent != rootState())) { | - | ||||||||||||||||||
760 | QFinalState *finalState = qobject_cast<QFinalState *>(s); | - | ||||||||||||||||||
761 | ((!(finalState)) ? qt_assert("finalState",__FILE__,10301036) : qt_noop()); | - | ||||||||||||||||||
762 | emitStateFinished(grandparent, finalState); | - | ||||||||||||||||||
763 | } | - | ||||||||||||||||||
764 | } | - | ||||||||||||||||||
765 | } | - | ||||||||||||||||||
766 | } | - | ||||||||||||||||||
767 | } | - | ||||||||||||||||||
768 | { | - | ||||||||||||||||||
769 | QSet<QAbstractState*>::const_iterator it; | - | ||||||||||||||||||
770 | for (it = configuration.constBegin(); it != configuration.constEnd(); ++it) { | - | ||||||||||||||||||
771 | if (isFinal(*it)) { | - | ||||||||||||||||||
772 | QState *parent = (*it)->parentState(); | - | ||||||||||||||||||
773 | if (((parent == rootState()) | - | ||||||||||||||||||
774 | && (rootState()->childMode() == QState::ExclusiveStates)) | - | ||||||||||||||||||
775 | || ((parent->parentState() == rootState()) | - | ||||||||||||||||||
776 | && (rootState()->childMode() == QState::ParallelStates) | - | ||||||||||||||||||
777 | && isInFinalState(rootState()))) { | - | ||||||||||||||||||
778 | processing = false; | - | ||||||||||||||||||
779 | stopProcessingReason = Finished; | - | ||||||||||||||||||
780 | break; | - | ||||||||||||||||||
781 | } | - | ||||||||||||||||||
782 | } | - | ||||||||||||||||||
783 | } | - | ||||||||||||||||||
784 | } | - | ||||||||||||||||||
785 | - | |||||||||||||||||||
786 | } | - | ||||||||||||||||||
787 | void QStateMachinePrivate::addDescendantStatesToEnter(QAbstractState *state, | - | ||||||||||||||||||
788 | QSet<QAbstractState*> &statesToEnter, | - | ||||||||||||||||||
789 | QSet<QAbstractState*> &statesForDefaultEntry) | - | ||||||||||||||||||
790 | { | - | ||||||||||||||||||
791 | if (QHistoryState *h = toHistoryState(state)
| 13-1506 | ||||||||||||||||||
792 | const QList<QAbstractState*> historyConfiguration = QHistoryStatePrivate::get(h)->configuration; | - | ||||||||||||||||||
793 | if (!historyConfiguration.isEmpty()
| 6-7 | ||||||||||||||||||
794 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(historyConfiguration)>::type> _container_((historyConfiguration)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QAbstractState *s = *_container_.i; _container_.control; _container_.control = 0: historyConfiguration) | - | ||||||||||||||||||
795 | addDescendantStatesToEnter(s, statesToEnter, statesForDefaultEntry); executed 11 times by 2 tests: addDescendantStatesToEnter(s, statesToEnter, statesForDefaultEntry); Executed by:
| 11 | ||||||||||||||||||
796 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(historyConfiguration)>::type> _container_((historyConfiguration)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QAbstractState *s = *_container_.i; _container_.control; _container_.control = 0: historyConfiguration) | - | ||||||||||||||||||
797 | addAncestorStatesToEnter(s, state->parentState(), statesToEnter, statesForDefaultEntry); executed 11 times by 2 tests: addAncestorStatesToEnter(s, state->parentState(), statesToEnter, statesForDefaultEntry); Executed by:
| 11 | ||||||||||||||||||
798 | - | |||||||||||||||||||
799 | - | |||||||||||||||||||
800 | - | |||||||||||||||||||
801 | - | |||||||||||||||||||
802 | - | |||||||||||||||||||
803 | - | |||||||||||||||||||
804 | } executed 7 times by 2 tests: else {end of block Executed by:
| 7 | ||||||||||||||||||
805 | QList<QAbstractState*> defaultHistoryContent; | - | ||||||||||||||||||
806 | if (QAbstractTransition *t = QHistoryStatePrivate::get(h)->defaultTransition
| 0-6 | ||||||||||||||||||
807 | defaultHistoryContent = t->targetStates(); executed 6 times by 2 tests: defaultHistoryContent = t->targetStates(); Executed by:
| 6 | ||||||||||||||||||
808 | - | |||||||||||||||||||
809 | if (defaultHistoryContent.isEmpty()
| 0-6 | ||||||||||||||||||
810 | setError(QStateMachine::NoDefaultStateInHistoryStateError, h); | - | ||||||||||||||||||
811 | } never executed: else {end of block | 0 | ||||||||||||||||||
812 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(defaultHistoryContent)>::type> _container_((defaultHistoryContent)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QAbstractState *s = *_container_.i; _container_.control; _container_.control = 0): qAsConst(defaultHistoryContent)) | - | ||||||||||||||||||
813 | addDescendantStatesToEnter(s, statesToEnter, statesForDefaultEntry); executed 7 times by 2 tests: addDescendantStatesToEnter(s, statesToEnter, statesForDefaultEntry); Executed by:
| 7 | ||||||||||||||||||
814 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(defaultHistoryContent)>::type> _container_((defaultHistoryContent)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QAbstractState *s = *_container_.i; _container_.control; _container_.control = 0): qAsConst(defaultHistoryContent)) | - | ||||||||||||||||||
815 | addAncestorStatesToEnter(s, state->parentState(), statesToEnter, statesForDefaultEntry); executed 7 times by 2 tests: addAncestorStatesToEnter(s, state->parentState(), statesToEnter, statesForDefaultEntry); Executed by:
| 7 | ||||||||||||||||||
816 | - | |||||||||||||||||||
817 | - | |||||||||||||||||||
818 | - | |||||||||||||||||||
819 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||
820 | } | - | ||||||||||||||||||
821 | } else { | - | ||||||||||||||||||
822 | if (state == rootState()
| 1-1505 | ||||||||||||||||||
823 | - | |||||||||||||||||||
824 | ((!(error != QStateMachine::NoError)) ? qt_assert("error != QStateMachine::NoError",__FILE__,11251131) : qt_noop()); | - | ||||||||||||||||||
825 | return; executed 1 time by 1 test: return; Executed by:
| 1 | ||||||||||||||||||
826 | } | - | ||||||||||||||||||
827 | statesToEnter.insert(state); | - | ||||||||||||||||||
828 | if (isCompound(state)
| 65-1440 | ||||||||||||||||||
829 | statesForDefaultEntry.insert(state); | - | ||||||||||||||||||
830 | if (QAbstractState *initial = toStandardState(state)->initialState()
| 16-49 | ||||||||||||||||||
831 | ((!(initial->machine() == q_func())) ? qt_assert("initial->machine() == q_func()",__FILE__,11321138) : qt_noop()); | - | ||||||||||||||||||
832 | - | |||||||||||||||||||
833 | - | |||||||||||||||||||
834 | - | |||||||||||||||||||
835 | - | |||||||||||||||||||
836 | - | |||||||||||||||||||
837 | statesForDefaultEntry.insert(initial); | - | ||||||||||||||||||
838 | - | |||||||||||||||||||
839 | addDescendantStatesToEnter(initial, statesToEnter, statesForDefaultEntry); | - | ||||||||||||||||||
840 | addAncestorStatesToEnter(initial, state, statesToEnter, statesForDefaultEntry); | - | ||||||||||||||||||
841 | } executed 49 times by 2 tests: else {end of block Executed by:
| 49 | ||||||||||||||||||
842 | setError(QStateMachine::NoInitialStateError, state); | - | ||||||||||||||||||
843 | return; executed 16 times by 1 test: return; Executed by:
| 16 | ||||||||||||||||||
844 | } | - | ||||||||||||||||||
845 | } else if (isParallel(state)
| 15-1425 | ||||||||||||||||||
846 | QState *grp = toStandardState(state); | - | ||||||||||||||||||
847 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(QStatePrivate::get(grp)->const auto childStates ())>::type> _container_((= QStatePrivate::get(grp)->childStates())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)(); | - | ||||||||||||||||||
848 | for (QAbstractState *child = *_container_.i; _container_.control; _container_.control = 0: childStates) { | - | ||||||||||||||||||
849 | if (!containsDecendantOf(statesToEnter, child)
| 0-29 | ||||||||||||||||||
850 | addDescendantStatesToEnter(child, statesToEnter, statesForDefaultEntry); executed 29 times by 1 test: addDescendantStatesToEnter(child, statesToEnter, statesForDefaultEntry); Executed by:
| 29 | ||||||||||||||||||
851 | } executed 29 times by 1 test: end of block Executed by:
| 29 | ||||||||||||||||||
852 | } executed 15 times by 1 test: end of block Executed by:
| 15 | ||||||||||||||||||
853 | } executed 1489 times by 2 tests: end of block Executed by:
| 1489 | ||||||||||||||||||
854 | } | - | ||||||||||||||||||
855 | void QStateMachinePrivate::addAncestorStatesToEnter(QAbstractState *s, QAbstractState *ancestor, | - | ||||||||||||||||||
856 | QSet<QAbstractState*> &statesToEnter, | - | ||||||||||||||||||
857 | QSet<QAbstractState*> &statesForDefaultEntry) | - | ||||||||||||||||||
858 | { | - | ||||||||||||||||||
859 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(getProperAncestors(s, ancestor))>::type> _container_((const auto properAncestors = getProperAncestors(s, ancestor))); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)); | - | ||||||||||||||||||
860 | for (QState *anc = *_container_.i; _container_.control; _container_.control = 0: properAncestors) { | - | ||||||||||||||||||
861 | if (!anc->parentState()
| 2-66 | ||||||||||||||||||
862 | continue; executed 2 times by 1 test: continue; Executed by:
| 2 | ||||||||||||||||||
863 | statesToEnter.insert(anc); | - | ||||||||||||||||||
864 | if (isParallel(anc)
| 31-35 | ||||||||||||||||||
865 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(QStatePrivate::get(anc)->const auto childStates ())>::type> _container_((= QStatePrivate::get(anc)->childStates())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)(); | - | ||||||||||||||||||
866 | for (QAbstractState *child = *_container_.i; _container_.control; _container_.control = 0: childStates) { | - | ||||||||||||||||||
867 | if (!containsDecendantOf(statesToEnter, child)
| 27-36 | ||||||||||||||||||
868 | addDescendantStatesToEnter(child, statesToEnter, statesForDefaultEntry); executed 27 times by 1 test: addDescendantStatesToEnter(child, statesToEnter, statesForDefaultEntry); Executed by:
| 27 | ||||||||||||||||||
869 | } executed 63 times by 1 test: end of block Executed by:
| 63 | ||||||||||||||||||
870 | } executed 35 times by 1 test: end of block Executed by:
| 35 | ||||||||||||||||||
871 | } executed 66 times by 1 test: end of block Executed by:
| 66 | ||||||||||||||||||
872 | } executed 1467 times by 2 tests: end of block Executed by:
| 1467 | ||||||||||||||||||
873 | - | |||||||||||||||||||
874 | bool QStateMachinePrivate::isFinal(const QAbstractState *s) | - | ||||||||||||||||||
875 | { | - | ||||||||||||||||||
876 | return s && (QAbstractStatePrivate::get(s)->stateType == QAbstractStatePrivate::FinalState); | - | ||||||||||||||||||
877 | } | - | ||||||||||||||||||
878 | - | |||||||||||||||||||
879 | bool QStateMachinePrivate::isParallel(const QAbstractState *s) | - | ||||||||||||||||||
880 | { | - | ||||||||||||||||||
881 | const QState *ss = toStandardState(s); | - | ||||||||||||||||||
882 | return ss && (QStatePrivate::get(ss)->childMode == QState::ParallelStates); | - | ||||||||||||||||||
883 | } | - | ||||||||||||||||||
884 | - | |||||||||||||||||||
885 | bool QStateMachinePrivate::isCompound(const QAbstractState *s) const | - | ||||||||||||||||||
886 | { | - | ||||||||||||||||||
887 | const QState *group = toStandardState(s); | - | ||||||||||||||||||
888 | if (!group) | - | ||||||||||||||||||
889 | return false; | - | ||||||||||||||||||
890 | bool isMachine = QStatePrivate::get(group)->isMachine; | - | ||||||||||||||||||
891 | - | |||||||||||||||||||
892 | if (isMachine && (group != rootState())) | - | ||||||||||||||||||
893 | return false; | - | ||||||||||||||||||
894 | return (!isParallel(group) && !QStatePrivate::get(group)->childStates().isEmpty()); | - | ||||||||||||||||||
895 | } | - | ||||||||||||||||||
896 | - | |||||||||||||||||||
897 | bool QStateMachinePrivate::isAtomic(const QAbstractState *s) const | - | ||||||||||||||||||
898 | { | - | ||||||||||||||||||
899 | const QState *ss = toStandardState(s); | - | ||||||||||||||||||
900 | return (ss && QStatePrivate::get(ss)->childStates().isEmpty()) | - | ||||||||||||||||||
901 | || isFinal(s) | - | ||||||||||||||||||
902 | - | |||||||||||||||||||
903 | || (ss && QStatePrivate::get(ss)->isMachine && (ss != rootState())); | - | ||||||||||||||||||
904 | } | - | ||||||||||||||||||
905 | - | |||||||||||||||||||
906 | QState *QStateMachinePrivate::toStandardState(QAbstractState *state) | - | ||||||||||||||||||
907 | { | - | ||||||||||||||||||
908 | if (state && (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::StandardState)) | - | ||||||||||||||||||
909 | return static_cast<QState*>(state); | - | ||||||||||||||||||
910 | return 0; | - | ||||||||||||||||||
911 | } | - | ||||||||||||||||||
912 | - | |||||||||||||||||||
913 | const QState *QStateMachinePrivate::toStandardState(const QAbstractState *state) | - | ||||||||||||||||||
914 | { | - | ||||||||||||||||||
915 | if (state && (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::StandardState)) | - | ||||||||||||||||||
916 | return static_cast<const QState*>(state); | - | ||||||||||||||||||
917 | return 0; | - | ||||||||||||||||||
918 | } | - | ||||||||||||||||||
919 | - | |||||||||||||||||||
920 | QFinalState *QStateMachinePrivate::toFinalState(QAbstractState *state) | - | ||||||||||||||||||
921 | { | - | ||||||||||||||||||
922 | if (state && (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::FinalState)) | - | ||||||||||||||||||
923 | return static_cast<QFinalState*>(state); | - | ||||||||||||||||||
924 | return 0; | - | ||||||||||||||||||
925 | } | - | ||||||||||||||||||
926 | - | |||||||||||||||||||
927 | QHistoryState *QStateMachinePrivate::toHistoryState(QAbstractState *state) | - | ||||||||||||||||||
928 | { | - | ||||||||||||||||||
929 | if (state && (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::HistoryState)) | - | ||||||||||||||||||
930 | return static_cast<QHistoryState*>(state); | - | ||||||||||||||||||
931 | return 0; | - | ||||||||||||||||||
932 | } | - | ||||||||||||||||||
933 | - | |||||||||||||||||||
934 | bool QStateMachinePrivate::isInFinalState(QAbstractState* s) const | - | ||||||||||||||||||
935 | { | - | ||||||||||||||||||
936 | if (isCompound(s)) { | - | ||||||||||||||||||
937 | QState *grp = toStandardState(s); | - | ||||||||||||||||||
938 | QList<QAbstractState*> lst = QStatePrivate::get(grp)->childStates(); | - | ||||||||||||||||||
939 | for (int i = 0; i < lst.size(); ++i) { | - | ||||||||||||||||||
940 | QAbstractState *cs = lst.at(i); | - | ||||||||||||||||||
941 | if (isFinal(cs) && configuration.contains(cs)) | - | ||||||||||||||||||
942 | return true; | - | ||||||||||||||||||
943 | } | - | ||||||||||||||||||
944 | return false; | - | ||||||||||||||||||
945 | } else if (isParallel(s)) { | - | ||||||||||||||||||
946 | QState *grp = toStandardState(s); | - | ||||||||||||||||||
947 | QList<QAbstractState*> lst = QStatePrivate::get(grp)->childStates(); | - | ||||||||||||||||||
948 | for (int i = 0; i < lst.size(); ++i) { | - | ||||||||||||||||||
949 | QAbstractState *cs = lst.at(i); | - | ||||||||||||||||||
950 | if (!isInFinalState(cs)) | - | ||||||||||||||||||
951 | return false; | - | ||||||||||||||||||
952 | } | - | ||||||||||||||||||
953 | return true; | - | ||||||||||||||||||
954 | } | - | ||||||||||||||||||
955 | else | - | ||||||||||||||||||
956 | return false; | - | ||||||||||||||||||
957 | } | - | ||||||||||||||||||
958 | bool QStateMachinePrivate::hasRestorable(QAbstractState *state, QObject *object, | - | ||||||||||||||||||
959 | const QByteArray &propertyName) const | - | ||||||||||||||||||
960 | { | - | ||||||||||||||||||
961 | RestorableId id(object, propertyName); | - | ||||||||||||||||||
962 | return registeredRestorablesForState.value(state).contains(id); | - | ||||||||||||||||||
963 | } | - | ||||||||||||||||||
964 | QVariant QStateMachinePrivate::savedValueForRestorable(const QList<QAbstractState*> &exitedStates_sorted, | - | ||||||||||||||||||
965 | QObject *object, const QByteArray &propertyName) const | - | ||||||||||||||||||
966 | { | - | ||||||||||||||||||
967 | - | |||||||||||||||||||
968 | - | |||||||||||||||||||
969 | - | |||||||||||||||||||
970 | for (int i = exitedStates_sorted.size() - 1; i >= 0; --i) { | - | ||||||||||||||||||
971 | QAbstractState *s = exitedStates_sorted.at(i); | - | ||||||||||||||||||
972 | QHash<RestorableId, QVariant> restorables = registeredRestorablesForState.value(s); | - | ||||||||||||||||||
973 | QHash<RestorableId, QVariant>::const_iterator it = restorables.constFind(RestorableId(object, propertyName)); | - | ||||||||||||||||||
974 | if (it != restorables.constEnd()) { | - | ||||||||||||||||||
975 | - | |||||||||||||||||||
976 | - | |||||||||||||||||||
977 | - | |||||||||||||||||||
978 | return it.value(); | - | ||||||||||||||||||
979 | } | - | ||||||||||||||||||
980 | } | - | ||||||||||||||||||
981 | - | |||||||||||||||||||
982 | - | |||||||||||||||||||
983 | - | |||||||||||||||||||
984 | return object->property(propertyName); | - | ||||||||||||||||||
985 | } | - | ||||||||||||||||||
986 | - | |||||||||||||||||||
987 | void QStateMachinePrivate::registerRestorable(QAbstractState *state, QObject *object, const QByteArray &propertyName, | - | ||||||||||||||||||
988 | const QVariant &value) | - | ||||||||||||||||||
989 | { | - | ||||||||||||||||||
990 | - | |||||||||||||||||||
991 | - | |||||||||||||||||||
992 | - | |||||||||||||||||||
993 | RestorableId id(object, propertyName); | - | ||||||||||||||||||
994 | QHash<RestorableId, QVariant> &restorables = registeredRestorablesForState[state]; | - | ||||||||||||||||||
995 | if (!restorables.contains(id)) | - | ||||||||||||||||||
996 | restorables.insert(id, value); | - | ||||||||||||||||||
997 | - | |||||||||||||||||||
998 | - | |||||||||||||||||||
999 | - | |||||||||||||||||||
1000 | - | |||||||||||||||||||
1001 | } | - | ||||||||||||||||||
1002 | - | |||||||||||||||||||
1003 | void QStateMachinePrivate::unregisterRestorables(const QList<QAbstractState *> &states, QObject *object, | - | ||||||||||||||||||
1004 | const QByteArray &propertyName) | - | ||||||||||||||||||
1005 | { | - | ||||||||||||||||||
1006 | - | |||||||||||||||||||
1007 | - | |||||||||||||||||||
1008 | - | |||||||||||||||||||
1009 | RestorableId id(object, propertyName); | - | ||||||||||||||||||
1010 | for (int i = 0; i < states.size()
| 65-70 | ||||||||||||||||||
1011 | QAbstractState *s = states.at(i); | - | ||||||||||||||||||
1012 | QHash<QAbstractState*, QHash<RestorableId, QVariant> >::iterator it; | - | ||||||||||||||||||
1013 | it = registeredRestorablesForState.find(s); | - | ||||||||||||||||||
1014 | if (it == registeredRestorablesForState.end()
| 24-46 | ||||||||||||||||||
1015 | continue; executed 24 times by 1 test: continue; Executed by:
| 24 | ||||||||||||||||||
1016 | QHash<RestorableId, QVariant> &restorables = it.value(); | - | ||||||||||||||||||
1017 | QHash<RestorableId, QVariant>::iterator it2;const auto it2 = restorables.findconstFind(id); | - | ||||||||||||||||||
1018 | if (it2 == restorables.endcend()
| 9-37 | ||||||||||||||||||
1019 | continue; executed 9 times by 1 test: continue; Executed by:
| 9 | ||||||||||||||||||
1020 | - | |||||||||||||||||||
1021 | - | |||||||||||||||||||
1022 | - | |||||||||||||||||||
1023 | restorables.erase(it2); | - | ||||||||||||||||||
1024 | if (restorables.isEmpty()
| 5-32 | ||||||||||||||||||
1025 | registeredRestorablesForState.erase(it); executed 32 times by 1 test: registeredRestorablesForState.erase(it); Executed by:
| 32 | ||||||||||||||||||
1026 | } executed 37 times by 1 test: end of block Executed by:
| 37 | ||||||||||||||||||
1027 | } executed 65 times by 1 test: end of block Executed by:
| 65 | ||||||||||||||||||
1028 | - | |||||||||||||||||||
1029 | QVector<QPropertyAssignment> QStateMachinePrivate::restorablesToPropertyList(const QHash<RestorableId, QVariant> &restorables) const | - | ||||||||||||||||||
1030 | { | - | ||||||||||||||||||
1031 | QVector<QPropertyAssignment> result; | - | ||||||||||||||||||
1032 | QHash<RestorableId, QVariant>::const_iterator it; | - | ||||||||||||||||||
1033 | for (it = restorables.constBegin(); it != restorables.constEnd(); ++it) { | - | ||||||||||||||||||
1034 | const RestorableId &id = it.key(); | - | ||||||||||||||||||
1035 | if (!id.object()) { | - | ||||||||||||||||||
1036 | - | |||||||||||||||||||
1037 | continue; | - | ||||||||||||||||||
1038 | } | - | ||||||||||||||||||
1039 | - | |||||||||||||||||||
1040 | - | |||||||||||||||||||
1041 | - | |||||||||||||||||||
1042 | result.append(QPropertyAssignment(id.object(), id.propertyName(), it.value(), false)); | - | ||||||||||||||||||
1043 | } | - | ||||||||||||||||||
1044 | return result; | - | ||||||||||||||||||
1045 | } | - | ||||||||||||||||||
1046 | QHash<QStateMachinePrivate::RestorableId, QVariant> QStateMachinePrivate::computePendingRestorables( | - | ||||||||||||||||||
1047 | const QList<QAbstractState*> &statesToExit_sorted) const | - | ||||||||||||||||||
1048 | { | - | ||||||||||||||||||
1049 | QHash<QStateMachinePrivate::RestorableId, QVariant> restorables; | - | ||||||||||||||||||
1050 | for (int i = statesToExit_sorted.size() - 1; i >= 0; --i) { | - | ||||||||||||||||||
1051 | QAbstractState *s = statesToExit_sorted.at(i); | - | ||||||||||||||||||
1052 | QHash<QStateMachinePrivate::RestorableId, QVariant> rs = registeredRestorablesForState.value(s); | - | ||||||||||||||||||
1053 | QHash<QStateMachinePrivate::RestorableId, QVariant>::const_iterator it; | - | ||||||||||||||||||
1054 | for (it = rs.constBegin(); it != rs.constEnd(); ++it) { | - | ||||||||||||||||||
1055 | if (!restorables.contains(it.key())) | - | ||||||||||||||||||
1056 | restorables.insert(it.key(), it.value()); | - | ||||||||||||||||||
1057 | } | - | ||||||||||||||||||
1058 | } | - | ||||||||||||||||||
1059 | return restorables; | - | ||||||||||||||||||
1060 | } | - | ||||||||||||||||||
1061 | QHash<QAbstractState*, QVector<QPropertyAssignment> > QStateMachinePrivate::computePropertyAssignments( | - | ||||||||||||||||||
1062 | const QList<QAbstractState*> &statesToEnter_sorted, QHash<RestorableId, QVariant> &pendingRestorables) const | - | ||||||||||||||||||
1063 | { | - | ||||||||||||||||||
1064 | QHash<QAbstractState*, QVector<QPropertyAssignment> > assignmentsForState; | - | ||||||||||||||||||
1065 | for (int i = 0; i < statesToEnter_sorted.size(); ++i) { | - | ||||||||||||||||||
1066 | QState *s = toStandardState(statesToEnter_sorted.at(i)); | - | ||||||||||||||||||
1067 | if (!s) | - | ||||||||||||||||||
1068 | continue; | - | ||||||||||||||||||
1069 | - | |||||||||||||||||||
1070 | QVector<QPropertyAssignment> &assignments = QStatePrivate::get(s)->propertyAssignments; | - | ||||||||||||||||||
1071 | for (int j = 0; j < assignments.size(); ++j) { | - | ||||||||||||||||||
1072 | const QPropertyAssignment &assn = assignments.at(j); | - | ||||||||||||||||||
1073 | if (assn.objectDeleted()) { | - | ||||||||||||||||||
1074 | assignments.removeAt(j--); | - | ||||||||||||||||||
1075 | } else { | - | ||||||||||||||||||
1076 | pendingRestorables.remove(RestorableId(assn.object, assn.propertyName)); | - | ||||||||||||||||||
1077 | assignmentsForState[s].append(assn); | - | ||||||||||||||||||
1078 | } | - | ||||||||||||||||||
1079 | } | - | ||||||||||||||||||
1080 | } | - | ||||||||||||||||||
1081 | return assignmentsForState; | - | ||||||||||||||||||
1082 | } | - | ||||||||||||||||||
1083 | - | |||||||||||||||||||
1084 | - | |||||||||||||||||||
1085 | - | |||||||||||||||||||
1086 | QAbstractState *QStateMachinePrivate::findErrorState(QAbstractState *context) | - | ||||||||||||||||||
1087 | { | - | ||||||||||||||||||
1088 | - | |||||||||||||||||||
1089 | QAbstractState *errorState = 0; | - | ||||||||||||||||||
1090 | if (context != 0) { | - | ||||||||||||||||||
1091 | QState *s = toStandardState(context); | - | ||||||||||||||||||
1092 | if (s != 0) | - | ||||||||||||||||||
1093 | errorState = s->errorState(); | - | ||||||||||||||||||
1094 | - | |||||||||||||||||||
1095 | if (errorState == 0) | - | ||||||||||||||||||
1096 | errorState = findErrorState(context->parentState()); | - | ||||||||||||||||||
1097 | } | - | ||||||||||||||||||
1098 | - | |||||||||||||||||||
1099 | return errorState; | - | ||||||||||||||||||
1100 | } | - | ||||||||||||||||||
1101 | - | |||||||||||||||||||
1102 | void QStateMachinePrivate::setError(QStateMachine::Error errorCode, QAbstractState *currentContext) | - | ||||||||||||||||||
1103 | { | - | ||||||||||||||||||
1104 | QStateMachine * const q = q_func(); | - | ||||||||||||||||||
1105 | - | |||||||||||||||||||
1106 | error = errorCode; | - | ||||||||||||||||||
1107 | switch (errorCode) { | - | ||||||||||||||||||
1108 | case executed 16 times by 1 test: QStateMachine::NoInitialStateError:case QStateMachine::NoInitialStateError: Executed by:
executed 16 times by 1 test: case QStateMachine::NoInitialStateError: Executed by:
| 16 | ||||||||||||||||||
1109 | ((!(currentContext != 0)) ? qt_assert("currentContext != 0",__FILE__,14621470) : qt_noop()); | - | ||||||||||||||||||
1110 | - | |||||||||||||||||||
1111 | errorString = QStateMachine::tr("Missing initial state in compound state '%1'") | - | ||||||||||||||||||
1112 | .arg(currentContext->objectName()); | - | ||||||||||||||||||
1113 | - | |||||||||||||||||||
1114 | break; executed 16 times by 1 test: break; Executed by:
| 16 | ||||||||||||||||||
1115 | case executed 1 time by 1 test: QStateMachine::NoDefaultStateInHistoryStateError:case QStateMachine::NoDefaultStateInHistoryStateError: Executed by:
executed 1 time by 1 test: case QStateMachine::NoDefaultStateInHistoryStateError: Executed by:
| 1 | ||||||||||||||||||
1116 | ((!(currentContext != 0)) ? qt_assert("currentContext != 0",__FILE__,14691477) : qt_noop()); | - | ||||||||||||||||||
1117 | - | |||||||||||||||||||
1118 | errorString = QStateMachine::tr("Missing default state in history state '%1'") | - | ||||||||||||||||||
1119 | .arg(currentContext->objectName()); | - | ||||||||||||||||||
1120 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||||||||
1121 | - | |||||||||||||||||||
1122 | case executed 3 times by 1 test: QStateMachine::NoCommonAncestorForTransitionError:case QStateMachine::NoCommonAncestorForTransitionError: Executed by:
executed 3 times by 1 test: case QStateMachine::NoCommonAncestorForTransitionError: Executed by:
| 3 | ||||||||||||||||||
1123 | ((!(currentContext != 0)) ? qt_assert("currentContext != 0",__FILE__,14761484) : qt_noop()); | - | ||||||||||||||||||
1124 | - | |||||||||||||||||||
1125 | errorString = QStateMachine::tr("No common ancestor for targets and source of transition from state '%1'") | - | ||||||||||||||||||
1126 | .arg(currentContext->objectName()); | - | ||||||||||||||||||
1127 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||||||||
1128 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||
1129 | errorString = QStateMachine::tr("Unknown error"); | - | ||||||||||||||||||
1130 | } never executed: ;end of block | 0 | ||||||||||||||||||
1131 | - | |||||||||||||||||||
1132 | pendingErrorStates.clear(); | - | ||||||||||||||||||
1133 | pendingErrorStatesForDefaultEntry.clear(); | - | ||||||||||||||||||
1134 | - | |||||||||||||||||||
1135 | QAbstractState *currentErrorState = findErrorState(currentContext); | - | ||||||||||||||||||
1136 | - | |||||||||||||||||||
1137 | - | |||||||||||||||||||
1138 | if (currentContext == currentErrorState
| 1-19 | ||||||||||||||||||
1139 | currentErrorState = 0; executed 1 time by 1 test: currentErrorState = 0; Executed by:
| 1 | ||||||||||||||||||
1140 | - | |||||||||||||||||||
1141 | ((!(currentErrorState != rootState())) ? qt_assert("currentErrorState != rootState()",__FILE__,14941502) : qt_noop()); | - | ||||||||||||||||||
1142 | - | |||||||||||||||||||
1143 | if (currentErrorState != 0
| 10 | ||||||||||||||||||
1144 | - | |||||||||||||||||||
1145 | - | |||||||||||||||||||
1146 | - | |||||||||||||||||||
1147 | pendingErrorStates.insert(currentErrorState); | - | ||||||||||||||||||
1148 | addDescendantStatesToEnter(currentErrorState, pendingErrorStates, pendingErrorStatesForDefaultEntry); | - | ||||||||||||||||||
1149 | addAncestorStatesToEnter(currentErrorState, rootState(), pendingErrorStates, pendingErrorStatesForDefaultEntry); | - | ||||||||||||||||||
1150 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(configuration)>::type> _container_((pendingErrorStates -= configuration)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QAbstractState *s = *_container_.i; _container_.control; | - | ||||||||||||||||||
1151 | _container_.control = 0) | 10 | ||||||||||||||||||
pendingErrorStates.remove(s);} executed 10 times by 1 test: else {end of block Executed by:
| ||||||||||||||||||||
1152 | QMessageLogger(__FILE__, 15061513, __PRETTY_FUNCTION__).warning("Unrecoverable error detected in running state machine: %s", | - | ||||||||||||||||||
1153 | QString(errorString).toLocal8Bit().constData()); | - | ||||||||||||||||||
1154 | q->stop(); | - | ||||||||||||||||||
1155 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||
1156 | } | - | ||||||||||||||||||
1157 | - | |||||||||||||||||||
1158 | - | |||||||||||||||||||
1159 | - | |||||||||||||||||||
QPair<QList<QAbstractAnimation*>, QList<QAbstractAnimation*> >QStateMachinePrivate::InitializeAnimationResult | ||||||||||||||||||||
1161 | QStateMachinePrivate::initializeAnimation(QAbstractAnimation *abstractAnimation, | - | ||||||||||||||||||
1162 | const QPropertyAssignment &prop) | - | ||||||||||||||||||
1163 | { | - | ||||||||||||||||||
1164 | QList<QAbstractAnimation*> handledAnimations; | - | ||||||||||||||||||
QList<QAbstractAnimation*> localResetEndValuesInitializeAnimationResult result; | ||||||||||||||||||||
1165 | QAnimationGroup *group = qobject_cast<QAnimationGroup*>(abstractAnimation); | - | ||||||||||||||||||
1166 | if (group
| 5-50 | ||||||||||||||||||
1167 | for (int i = 0; i < group->animationCount()
| 5-8 | ||||||||||||||||||
1168 | QAbstractAnimation *animationChild = group->animationAt(i); | - | ||||||||||||||||||
1169 | QPair<QList<QAbstractAnimation*>, QList<QAbstractAnimation*> > ret;const auto ret = initializeAnimation(animationChild, prop); | - | ||||||||||||||||||
1170 | result.handledAnimations << ret.firsthandledAnimations; | - | ||||||||||||||||||
1171 | result.localResetEndValues << ret.secondlocalResetEndValues; | - | ||||||||||||||||||
1172 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
1173 | } executed 5 times by 1 test: else {end of block Executed by:
| 5 | ||||||||||||||||||
1174 | QPropertyAnimation *animation = qobject_cast<QPropertyAnimation *>(abstractAnimation); | - | ||||||||||||||||||
1175 | if (animation != 0
| 0-50 | ||||||||||||||||||
1176 | && prop.object == animation->targetObject()
| 4-46 | ||||||||||||||||||
1177 | && prop.propertyName == animation->propertyName()
| 10-36 | ||||||||||||||||||
1178 | - | |||||||||||||||||||
1179 | - | |||||||||||||||||||
1180 | if (!animation->endValue().isValid()
| 1-35 | ||||||||||||||||||
1181 | animation->setEndValue(prop.value); | - | ||||||||||||||||||
1182 | result.localResetEndValues.append(animation); | - | ||||||||||||||||||
1183 | } executed 35 times by 1 test: end of block Executed by:
| 35 | ||||||||||||||||||
1184 | result.handledAnimations.append(animation); | - | ||||||||||||||||||
1185 | } executed 36 times by 1 test: end of block Executed by:
| 36 | ||||||||||||||||||
1186 | } executed 50 times by 1 test: end of block Executed by:
| 50 | ||||||||||||||||||
1187 | return executed 55 times by 1 test: qMakePair(handledAnimations, localResetEndValues);result;return result; Executed by:
executed 55 times by 1 test: return result; Executed by:
| 55 | ||||||||||||||||||
1188 | } | - | ||||||||||||||||||
1189 | - | |||||||||||||||||||
1190 | void QStateMachinePrivate::_q_animationFinished() | - | ||||||||||||||||||
1191 | { | - | ||||||||||||||||||
1192 | QStateMachine * const q = q_func(); | - | ||||||||||||||||||
1193 | QAbstractAnimation *anim = qobject_cast<QAbstractAnimation*>(q->sender()); | - | ||||||||||||||||||
1194 | ((!(anim != 0)) ? qt_assert("anim != 0",__FILE__,15501555) : qt_noop()); | - | ||||||||||||||||||
1195 | QObject::disconnect(anim, qFlagLocation("2""finished()" "\0" __FILE__ ":" "1551""1556"), q, qFlagLocation("1""_q_animationFinished()" "\0" __FILE__ ":" "1551""1556")); | - | ||||||||||||||||||
1196 | if (resetAnimationEndValues.contains(anim)) { | - | ||||||||||||||||||
1197 | qobject_cast<QVariantAnimation*>(anim)->setEndValue(QVariant()); | - | ||||||||||||||||||
1198 | resetAnimationEndValues.remove(anim); | - | ||||||||||||||||||
1199 | } | - | ||||||||||||||||||
1200 | - | |||||||||||||||||||
1201 | QAbstractState *state = stateForAnimation.take(anim); | - | ||||||||||||||||||
1202 | ((!(state != 0)) ? qt_assert("state != 0",__FILE__,15581563) : qt_noop()); | - | ||||||||||||||||||
1203 | - | |||||||||||||||||||
1204 | - | |||||||||||||||||||
1205 | - | |||||||||||||||||||
1206 | QPropertyAssignment assn = propertyForAnimation.take(anim); | - | ||||||||||||||||||
1207 | assn.write(); | - | ||||||||||||||||||
1208 | if (!assn.explicitlySet) | - | ||||||||||||||||||
1209 | unregisterRestorables(QList<QAbstractState*>() << state, assn.object, assn.propertyName); | - | ||||||||||||||||||
1210 | - | |||||||||||||||||||
1211 | - | |||||||||||||||||||
1212 | QHash<QAbstractState*, QList<QAbstractAnimation*> >::iterator it; | - | ||||||||||||||||||
1213 | it = animationsForState.find(state); | - | ||||||||||||||||||
1214 | ((!(it != animationsForState.end())) ? qt_assert("it != animationsForState.end()",__FILE__,15701575) : qt_noop()); | - | ||||||||||||||||||
1215 | QList<QAbstractAnimation*> &animations = it.value(); | - | ||||||||||||||||||
1216 | animations.removeOne(anim); | - | ||||||||||||||||||
1217 | if (animations.isEmpty()) { | - | ||||||||||||||||||
1218 | animationsForState.erase(it); | - | ||||||||||||||||||
1219 | QStatePrivate::get(toStandardState(state))->emitPropertiesAssigned(); | - | ||||||||||||||||||
1220 | } | - | ||||||||||||||||||
1221 | } | - | ||||||||||||||||||
1222 | - | |||||||||||||||||||
1223 | QList<QAbstractAnimation *> QStateMachinePrivate::selectAnimations(const QList<QAbstractTransition *> &transitionList) const | - | ||||||||||||||||||
1224 | { | - | ||||||||||||||||||
1225 | QList<QAbstractAnimation *> selectedAnimations; | - | ||||||||||||||||||
1226 | if (animated) { | - | ||||||||||||||||||
1227 | for (int i = 0; i < transitionList.size(); ++i) { | - | ||||||||||||||||||
1228 | QAbstractTransition *transition = transitionList.at(i); | - | ||||||||||||||||||
1229 | - | |||||||||||||||||||
1230 | selectedAnimations << transition->animations(); | - | ||||||||||||||||||
1231 | selectedAnimations << defaultAnimationsForSource.values(transition->sourceState()); | - | ||||||||||||||||||
1232 | - | |||||||||||||||||||
1233 | QList<QAbstractState *> targetStates = transition->targetStates(); | - | ||||||||||||||||||
1234 | for (int j=0; j<targetStates.size(); ++j) | - | ||||||||||||||||||
1235 | selectedAnimations << defaultAnimationsForTarget.values(targetStates.at(j)); | - | ||||||||||||||||||
1236 | } | - | ||||||||||||||||||
1237 | selectedAnimations << defaultAnimations; | - | ||||||||||||||||||
1238 | } | - | ||||||||||||||||||
1239 | return selectedAnimations; | - | ||||||||||||||||||
1240 | } | - | ||||||||||||||||||
1241 | - | |||||||||||||||||||
1242 | void QStateMachinePrivate::terminateActiveAnimations(QAbstractState *state, | - | ||||||||||||||||||
1243 | const QHash<QAbstractState*, QVector<QPropertyAssignment> > &assignmentsForEnteredStates) | - | ||||||||||||||||||
1244 | { | - | ||||||||||||||||||
1245 | QStateMachine * const q = q_func(); | - | ||||||||||||||||||
1246 | QList<QAbstractAnimation*> animations = animationsForState.take(state); | - | ||||||||||||||||||
1247 | for (int i = 0; i < animations.size(); ++i) { | - | ||||||||||||||||||
1248 | QAbstractAnimation *anim = animations.at(i); | - | ||||||||||||||||||
1249 | QObject::disconnect(anim, qFlagLocation("2""finished()" "\0" __FILE__ ":" "1605""1610"), q, qFlagLocation("1""_q_animationFinished()" "\0" __FILE__ ":" "1605""1610")); | - | ||||||||||||||||||
1250 | stateForAnimation.remove(anim); | - | ||||||||||||||||||
1251 | - | |||||||||||||||||||
1252 | - | |||||||||||||||||||
1253 | - | |||||||||||||||||||
1254 | QAbstractAnimation *topLevelAnim = anim; | - | ||||||||||||||||||
1255 | while (QAnimationGroup *group = topLevelAnim->group()) | - | ||||||||||||||||||
1256 | topLevelAnim = group; | - | ||||||||||||||||||
1257 | topLevelAnim->stop(); | - | ||||||||||||||||||
1258 | - | |||||||||||||||||||
1259 | if (resetAnimationEndValues.contains(anim)) { | - | ||||||||||||||||||
1260 | qobject_cast<QVariantAnimation*>(anim)->setEndValue(QVariant()); | - | ||||||||||||||||||
1261 | resetAnimationEndValues.remove(anim); | - | ||||||||||||||||||
1262 | } | - | ||||||||||||||||||
1263 | QPropertyAssignment assn = propertyForAnimation.take(anim); | - | ||||||||||||||||||
1264 | ((!(assn.object != 0)) ? qt_assert("assn.object != 0",__FILE__,16201625) : qt_noop()); | - | ||||||||||||||||||
1265 | - | |||||||||||||||||||
1266 | - | |||||||||||||||||||
1267 | bool found = false; | - | ||||||||||||||||||
1268 | QHash<QAbstractState*, QVector<QPropertyAssignment> >::const_iterator it; | - | ||||||||||||||||||
1269 | for (it = assignmentsForEnteredStates.constBegin(); it != assignmentsForEnteredStates.constEnd(); ++it) { | - | ||||||||||||||||||
1270 | const QVector<QPropertyAssignment> &assignments = it.value(); | - | ||||||||||||||||||
1271 | for (int j = 0; j < assignments.size(); ++j) { | - | ||||||||||||||||||
1272 | if (assignments.at(j).hasTarget(assn.object, assn.propertyName)) { | - | ||||||||||||||||||
1273 | found = true; | - | ||||||||||||||||||
1274 | break; | - | ||||||||||||||||||
1275 | } | - | ||||||||||||||||||
1276 | } | - | ||||||||||||||||||
1277 | } | - | ||||||||||||||||||
1278 | if (!found) { | - | ||||||||||||||||||
1279 | assn.write(); | - | ||||||||||||||||||
1280 | if (!assn.explicitlySet) | - | ||||||||||||||||||
1281 | unregisterRestorables(QList<QAbstractState*>() << state, assn.object, assn.propertyName); | - | ||||||||||||||||||
1282 | } | - | ||||||||||||||||||
1283 | } | - | ||||||||||||||||||
1284 | } | - | ||||||||||||||||||
1285 | - | |||||||||||||||||||
1286 | void QStateMachinePrivate::initializeAnimations(QAbstractState *state, const QList<QAbstractAnimation *> &selectedAnimations, | - | ||||||||||||||||||
1287 | const QList<QAbstractState*> &exitedStates_sorted, | - | ||||||||||||||||||
1288 | QHash<QAbstractState*, QVector<QPropertyAssignment> > &assignmentsForEnteredStates) | - | ||||||||||||||||||
1289 | { | - | ||||||||||||||||||
1290 | QStateMachine * const q = q_func(); | - | ||||||||||||||||||
1291 | if (!assignmentsForEnteredStates.contains(state)
| 115-1392 | ||||||||||||||||||
1292 | return; executed 1392 times by 2 tests: return; Executed by:
| 1392 | ||||||||||||||||||
1293 | QVector<QPropertyAssignment> &assignments = assignmentsForEnteredStates[state]; | - | ||||||||||||||||||
1294 | for (int i = 0; i < selectedAnimations.size()
| 41-85 | ||||||||||||||||||
1295 | QAbstractAnimation *anim = selectedAnimations.at(i); | - | ||||||||||||||||||
1296 | QVector<QPropertyAssignment>::iterator it; | - | ||||||||||||||||||
1297 | for (it = assignments.begin(); it != assignments.end()
| 41-47 | ||||||||||||||||||
1298 | QPair<QList<QAbstractAnimation*>, QList<QAbstractAnimation*> > ret;const QPropertyAssignment &assn = *it; | - | ||||||||||||||||||
1299 | const auto ret = initializeAnimation(anim, assn); | - | ||||||||||||||||||
1300 | QList<QAbstractAnimation*> handlers = ret.first;if (!handlersret.handledAnimations.isEmpty()
| 11-36 | ||||||||||||||||||
1301 | for (int j = 0; j < handlersret.handledAnimations.size()
| 36 | ||||||||||||||||||
1302 | QAbstractAnimation *a = handlersret.handledAnimations.at(j); | - | ||||||||||||||||||
1303 | propertyForAnimation.insert(a, assn); | - | ||||||||||||||||||
1304 | stateForAnimation.insert(a, state); | - | ||||||||||||||||||
1305 | animationsForState[state].append(a); | - | ||||||||||||||||||
1306 | - | |||||||||||||||||||
1307 | QObject::connect(a, qFlagLocation("2""finished()" "\0" __FILE__ ":" "1665""1668"), q, qFlagLocation("1""_q_animationFinished()" "\0" __FILE__ ":" "1665""1668"), Qt::UniqueConnection); | - | ||||||||||||||||||
1308 | } executed 36 times by 1 test: end of block Executed by:
| 36 | ||||||||||||||||||
1309 | if ((
| 12-24 | ||||||||||||||||||
1310 | && !hasRestorable(state, assn.object, assn.propertyName)
| 0-12 | ||||||||||||||||||
1311 | QVariant value = savedValueForRestorable(exitedStates_sorted, assn.object, assn.propertyName); | - | ||||||||||||||||||
1312 | unregisterRestorables(exitedStates_sorted, assn.object, assn.propertyName); | - | ||||||||||||||||||
1313 | registerRestorable(state, assn.object, assn.propertyName, value); | - | ||||||||||||||||||
1314 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||
1315 | it = assignments.erase(it); | - | ||||||||||||||||||
1316 | } executed 36 times by 1 test: else {end of block Executed by:
| 36 | ||||||||||||||||||
1317 | ++it; | - | ||||||||||||||||||
1318 | } executed 11 times by 1 test: end of block Executed by:
| 11 | ||||||||||||||||||
1319 | for (int j = 0; j < ret.secondlocalResetEndValues.size()
| 35-47 | ||||||||||||||||||
1320 | resetAnimationEndValues.insert(ret.secondlocalResetEndValues.at(j)); executed 35 times by 1 test: resetAnimationEndValues.insert(ret.localResetEndValues.at(j)); Executed by:
| 35 | ||||||||||||||||||
1321 | } executed 47 times by 1 test: end of block Executed by:
| 47 | ||||||||||||||||||
1322 | - | |||||||||||||||||||
1323 | - | |||||||||||||||||||
1324 | QList<QVariantAnimation*> variantAnims = anim->findChildren<QVariantAnimation*>(); | - | ||||||||||||||||||
1325 | if (QVariantAnimation *va = qobject_cast<QVariantAnimation*>(anim)
| 3-38 | ||||||||||||||||||
1326 | variantAnims.append(va); executed 38 times by 1 test: variantAnims.append(va); Executed by:
| 38 | ||||||||||||||||||
1327 | - | |||||||||||||||||||
1328 | bool hasValidEndValue = false; | - | ||||||||||||||||||
1329 | for (int j = 0; j < variantAnims.size()
| 2-41 | ||||||||||||||||||
1330 | if (variantAnims.at(j)->endValue().isValid()
| 2-39 | ||||||||||||||||||
1331 | hasValidEndValue = true; | - | ||||||||||||||||||
1332 | break; executed 39 times by 1 test: break; Executed by:
| 39 | ||||||||||||||||||
1333 | } | - | ||||||||||||||||||
1334 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
1335 | - | |||||||||||||||||||
1336 | if (hasValidEndValue
| 2-39 | ||||||||||||||||||
1337 | if (anim->state() == QAbstractAnimation::Running
| 5-34 | ||||||||||||||||||
1338 | - | |||||||||||||||||||
1339 | - | |||||||||||||||||||
1340 | - | |||||||||||||||||||
1341 | - | |||||||||||||||||||
1342 | - | |||||||||||||||||||
1343 | anim->stop(); | - | ||||||||||||||||||
1344 | } executed 5 times by 1 test: end of block Executed by:
| 5 | ||||||||||||||||||
1345 | anim->start(); | - | ||||||||||||||||||
1346 | } executed 39 times by 1 test: end of block Executed by:
| 39 | ||||||||||||||||||
1347 | - | |||||||||||||||||||
1348 | if (assignments.isEmpty()
| 11-30 | ||||||||||||||||||
1349 | assignmentsForEnteredStates.remove(state); | - | ||||||||||||||||||
1350 | break; executed 30 times by 1 test: break; Executed by:
| 30 | ||||||||||||||||||
1351 | } | - | ||||||||||||||||||
1352 | } executed 11 times by 1 test: end of block Executed by:
| 11 | ||||||||||||||||||
1353 | } executed 115 times by 2 tests: end of block Executed by:
| 115 | ||||||||||||||||||
1354 | - | |||||||||||||||||||
1355 | - | |||||||||||||||||||
1356 | - | |||||||||||||||||||
1357 | QAbstractTransition *QStateMachinePrivate::createInitialTransition() const | - | ||||||||||||||||||
1358 | { | - | ||||||||||||||||||
1359 | class InitialTransition : public QAbstractTransition | - | ||||||||||||||||||
1360 | { | - | ||||||||||||||||||
1361 | public: | - | ||||||||||||||||||
1362 | InitialTransition(const QList<QAbstractState *> &targets) | - | ||||||||||||||||||
1363 | : QAbstractTransition() | - | ||||||||||||||||||
1364 | { setTargetStates(targets); } | - | ||||||||||||||||||
1365 | protected: | - | ||||||||||||||||||
1366 | virtual bool eventTest(QEvent *) override { return true; } | - | ||||||||||||||||||
1367 | virtual void onTransition(QEvent *) override {} | - | ||||||||||||||||||
1368 | }; | - | ||||||||||||||||||
1369 | - | |||||||||||||||||||
1370 | QState *root = rootState(); | - | ||||||||||||||||||
1371 | ((!(root != 0)) ? qt_assert("root != 0",__FILE__,17291732) : qt_noop()); | - | ||||||||||||||||||
1372 | QList<QAbstractState *> targets; | - | ||||||||||||||||||
1373 | switch (root->childMode()) { | - | ||||||||||||||||||
1374 | case QState::ExclusiveStates: | - | ||||||||||||||||||
1375 | targets.append(root->initialState()); | - | ||||||||||||||||||
1376 | break; | - | ||||||||||||||||||
1377 | case QState::ParallelStates: | - | ||||||||||||||||||
1378 | targets = QStatePrivate::get(root)->childStates(); | - | ||||||||||||||||||
1379 | break; | - | ||||||||||||||||||
1380 | } | - | ||||||||||||||||||
1381 | return new InitialTransition(targets); | - | ||||||||||||||||||
1382 | } | - | ||||||||||||||||||
1383 | - | |||||||||||||||||||
1384 | void QStateMachinePrivate::clearHistory() | - | ||||||||||||||||||
1385 | { | - | ||||||||||||||||||
1386 | QStateMachine * const q = q_func(); | - | ||||||||||||||||||
1387 | QList<QHistoryState*> historyStates = q->findChildren<QHistoryState*>(); | - | ||||||||||||||||||
1388 | for (int i = 0; i < historyStates.size(); ++i) { | - | ||||||||||||||||||
1389 | QHistoryState *h = historyStates.at(i); | - | ||||||||||||||||||
1390 | QHistoryStatePrivate::get(h)->configuration.clear(); | - | ||||||||||||||||||
1391 | } | - | ||||||||||||||||||
1392 | } | - | ||||||||||||||||||
1393 | void QStateMachinePrivate::registerMultiThreadedSignalTransitions() | - | ||||||||||||||||||
1394 | { | - | ||||||||||||||||||
1395 | QStateMachine * const q = q_func(); | - | ||||||||||||||||||
1396 | QList<QSignalTransition*> transitions = rootState()->findChildren<QSignalTransition*>(); | - | ||||||||||||||||||
1397 | for (int i = 0; i < transitions.size(); ++i) { | - | ||||||||||||||||||
1398 | QSignalTransition *t = transitions.at(i); | - | ||||||||||||||||||
1399 | if ((t->machine() == q) && t->senderObject() && (t->senderObject()->thread() != q->thread())) | - | ||||||||||||||||||
1400 | registerSignalTransition(t); | - | ||||||||||||||||||
1401 | } | - | ||||||||||||||||||
1402 | } | - | ||||||||||||||||||
1403 | - | |||||||||||||||||||
1404 | void QStateMachinePrivate::_q_start() | - | ||||||||||||||||||
1405 | { | - | ||||||||||||||||||
1406 | QStateMachine * const q = q_func(); | - | ||||||||||||||||||
1407 | ((!(state == Starting)) ? qt_assert("state == Starting",__FILE__,17771780) : qt_noop()); | - | ||||||||||||||||||
1408 | - | |||||||||||||||||||
1409 | - | |||||||||||||||||||
1410 | - | |||||||||||||||||||
1411 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(configuration)>::type> _container_((const auto config = configuration)); _container_.control && _container_.i != _container_.e; | - | ||||||||||||||||||
1412 | ++_container_.i, _container_.control ^= 1)for (QAbstractState *state = *_container_.i; _container_.control; _container_.control = 0: config) { | - | ||||||||||||||||||
1413 | QAbstractStatePrivate *abstractStatePrivate = QAbstractStatePrivate::get(state); | - | ||||||||||||||||||
1414 | abstractStatePrivate->active = false; | - | ||||||||||||||||||
1415 | state->activeChanged(false); | - | ||||||||||||||||||
1416 | } executed 25 times by 1 test: end of block Executed by:
| 25 | ||||||||||||||||||
1417 | configuration.clear(); | - | ||||||||||||||||||
1418 | qDeleteAll(internalEventQueue); | - | ||||||||||||||||||
1419 | internalEventQueue.clear(); | - | ||||||||||||||||||
1420 | qDeleteAll(externalEventQueue); | - | ||||||||||||||||||
1421 | externalEventQueue.clear(); | - | ||||||||||||||||||
1422 | clearHistory(); | - | ||||||||||||||||||
1423 | - | |||||||||||||||||||
1424 | registerMultiThreadedSignalTransitions(); | - | ||||||||||||||||||
1425 | - | |||||||||||||||||||
1426 | startupHook(); | - | ||||||||||||||||||
1427 | - | |||||||||||||||||||
1428 | - | |||||||||||||||||||
1429 | - | |||||||||||||||||||
1430 | - | |||||||||||||||||||
1431 | state = Running; | - | ||||||||||||||||||
1432 | processingScheduled = true; | - | ||||||||||||||||||
1433 | - | |||||||||||||||||||
1434 | QList<QAbstractTransition*> transitions; | - | ||||||||||||||||||
1435 | CalculationCache calculationCache; | - | ||||||||||||||||||
1436 | QAbstractTransition *initialTransition = createInitialTransition(); | - | ||||||||||||||||||
1437 | transitions.append(initialTransition); | - | ||||||||||||||||||
1438 | - | |||||||||||||||||||
1439 | QEvent nullEvent(QEvent::None); | - | ||||||||||||||||||
1440 | executeTransitionContent(&nullEvent, transitions); | - | ||||||||||||||||||
1441 | QList<QAbstractState*> exitedStates = QList<QAbstractState*>(); | - | ||||||||||||||||||
1442 | QSet<QAbstractState*> statesForDefaultEntry; | - | ||||||||||||||||||
1443 | QList<QAbstractState*> enteredStates = computeEntrySet(transitions, statesForDefaultEntry, &calculationCache); | - | ||||||||||||||||||
1444 | QHash<RestorableId, QVariant> pendingRestorables; | - | ||||||||||||||||||
1445 | QHash<QAbstractState*, QVector<QPropertyAssignment> > assignmentsForEnteredStates = | - | ||||||||||||||||||
1446 | computePropertyAssignments(enteredStates, pendingRestorables); | - | ||||||||||||||||||
1447 | - | |||||||||||||||||||
1448 | QList<QAbstractAnimation*> selectedAnimations = selectAnimations(transitions); | - | ||||||||||||||||||
1449 | - | |||||||||||||||||||
1450 | - | |||||||||||||||||||
1451 | - | |||||||||||||||||||
1452 | stopProcessingReason = EventQueueEmpty; | - | ||||||||||||||||||
1453 | enterStates(&nullEvent, exitedStates, enteredStates, statesForDefaultEntry, | - | ||||||||||||||||||
1454 | assignmentsForEnteredStates | - | ||||||||||||||||||
1455 | - | |||||||||||||||||||
1456 | , selectedAnimations | - | ||||||||||||||||||
1457 | - | |||||||||||||||||||
1458 | ); | - | ||||||||||||||||||
1459 | delete initialTransition; | - | ||||||||||||||||||
1460 | - | |||||||||||||||||||
1461 | - | |||||||||||||||||||
1462 | - | |||||||||||||||||||
1463 | - | |||||||||||||||||||
1464 | - | |||||||||||||||||||
1465 | q->started(QStateMachine::QPrivateSignal()); | - | ||||||||||||||||||
1466 | q->runningChanged(true); | - | ||||||||||||||||||
1467 | - | |||||||||||||||||||
1468 | if (stopProcessingReason == Finished
| 2-151 | ||||||||||||||||||
1469 | - | |||||||||||||||||||
1470 | processingScheduled = false; | - | ||||||||||||||||||
1471 | state = NotRunning; | - | ||||||||||||||||||
1472 | unregisterAllTransitions(); | - | ||||||||||||||||||
1473 | emitFinished(); | - | ||||||||||||||||||
1474 | q->runningChanged(false); | - | ||||||||||||||||||
1475 | exitInterpreter(); | - | ||||||||||||||||||
1476 | } executed 2 times by 1 test: else {end of block Executed by:
| 2 | ||||||||||||||||||
1477 | _q_process(); | - | ||||||||||||||||||
1478 | } executed 151 times by 2 tests: end of block Executed by:
| 151 | ||||||||||||||||||
1479 | } | - | ||||||||||||||||||
1480 | - | |||||||||||||||||||
1481 | void QStateMachinePrivate::_q_process() | - | ||||||||||||||||||
1482 | { | - | ||||||||||||||||||
1483 | QStateMachine * const q = q_func(); | - | ||||||||||||||||||
1484 | ((!(state == Running)) ? qt_assert("state == Running",__FILE__,18501857) : qt_noop()); | - | ||||||||||||||||||
1485 | ((!(!processing)) ? qt_assert("!processing",__FILE__,18511858) : qt_noop()); | - | ||||||||||||||||||
1486 | processing = true; | - | ||||||||||||||||||
1487 | processingScheduled = false; | - | ||||||||||||||||||
1488 | beginMacrostep(); | - | ||||||||||||||||||
1489 | - | |||||||||||||||||||
1490 | - | |||||||||||||||||||
1491 | - | |||||||||||||||||||
1492 | bool didChange = false; | - | ||||||||||||||||||
1493 | while (processing) { | - | ||||||||||||||||||
1494 | if (stop) { | - | ||||||||||||||||||
1495 | processing = false; | - | ||||||||||||||||||
1496 | break; | - | ||||||||||||||||||
1497 | } | - | ||||||||||||||||||
1498 | QList<QAbstractTransition*> enabledTransitions; | - | ||||||||||||||||||
1499 | CalculationCache calculationCache; | - | ||||||||||||||||||
1500 | - | |||||||||||||||||||
1501 | QEvent *e = new QEvent(QEvent::None); | - | ||||||||||||||||||
1502 | enabledTransitions = selectTransitions(e, &calculationCache); | - | ||||||||||||||||||
1503 | if (enabledTransitions.isEmpty()) { | - | ||||||||||||||||||
1504 | delete e; | - | ||||||||||||||||||
1505 | e = 0; | - | ||||||||||||||||||
1506 | } | - | ||||||||||||||||||
1507 | while (enabledTransitions.isEmpty() && ((e = dequeueInternalEvent()) != 0)) { | - | ||||||||||||||||||
1508 | - | |||||||||||||||||||
1509 | - | |||||||||||||||||||
1510 | - | |||||||||||||||||||
1511 | enabledTransitions = selectTransitions(e, &calculationCache); | - | ||||||||||||||||||
1512 | if (enabledTransitions.isEmpty()) { | - | ||||||||||||||||||
1513 | delete e; | - | ||||||||||||||||||
1514 | e = 0; | - | ||||||||||||||||||
1515 | } | - | ||||||||||||||||||
1516 | } | - | ||||||||||||||||||
1517 | while (enabledTransitions.isEmpty() && ((e = dequeueExternalEvent()) != 0)) { | - | ||||||||||||||||||
1518 | - | |||||||||||||||||||
1519 | - | |||||||||||||||||||
1520 | - | |||||||||||||||||||
1521 | enabledTransitions = selectTransitions(e, &calculationCache); | - | ||||||||||||||||||
1522 | if (enabledTransitions.isEmpty()) { | - | ||||||||||||||||||
1523 | delete e; | - | ||||||||||||||||||
1524 | e = 0; | - | ||||||||||||||||||
1525 | } | - | ||||||||||||||||||
1526 | } | - | ||||||||||||||||||
1527 | if (enabledTransitions.isEmpty()) { | - | ||||||||||||||||||
1528 | if (isInternalEventQueueEmpty()) { | - | ||||||||||||||||||
1529 | processing = false; | - | ||||||||||||||||||
1530 | stopProcessingReason = EventQueueEmpty; | - | ||||||||||||||||||
1531 | noMicrostep(); | - | ||||||||||||||||||
1532 | - | |||||||||||||||||||
1533 | - | |||||||||||||||||||
1534 | - | |||||||||||||||||||
1535 | } | - | ||||||||||||||||||
1536 | } else { | - | ||||||||||||||||||
1537 | didChange = true; | - | ||||||||||||||||||
1538 | q->beginMicrostep(e); | - | ||||||||||||||||||
1539 | microstep(e, enabledTransitions, &calculationCache); | - | ||||||||||||||||||
1540 | q->endMicrostep(e); | - | ||||||||||||||||||
1541 | } | - | ||||||||||||||||||
1542 | delete e; | - | ||||||||||||||||||
1543 | } | - | ||||||||||||||||||
1544 | - | |||||||||||||||||||
1545 | - | |||||||||||||||||||
1546 | - | |||||||||||||||||||
1547 | if (stop) { | - | ||||||||||||||||||
1548 | stop = false; | - | ||||||||||||||||||
1549 | stopProcessingReason = Stopped; | - | ||||||||||||||||||
1550 | } | - | ||||||||||||||||||
1551 | - | |||||||||||||||||||
1552 | switch (stopProcessingReason) { | - | ||||||||||||||||||
1553 | case EventQueueEmpty: | - | ||||||||||||||||||
1554 | processedPendingEvents(didChange); | - | ||||||||||||||||||
1555 | break; | - | ||||||||||||||||||
1556 | case Finished: | - | ||||||||||||||||||
1557 | state = NotRunning; | - | ||||||||||||||||||
1558 | cancelAllDelayedEvents(); | - | ||||||||||||||||||
1559 | unregisterAllTransitions(); | - | ||||||||||||||||||
1560 | emitFinished(); | - | ||||||||||||||||||
1561 | q->runningChanged(false); | - | ||||||||||||||||||
1562 | break; | - | ||||||||||||||||||
1563 | case Stopped: | - | ||||||||||||||||||
1564 | state = NotRunning; | - | ||||||||||||||||||
1565 | cancelAllDelayedEvents(); | - | ||||||||||||||||||
1566 | unregisterAllTransitions(); | - | ||||||||||||||||||
1567 | q->stopped(QStateMachine::QPrivateSignal()); | - | ||||||||||||||||||
1568 | q->runningChanged(false); | - | ||||||||||||||||||
1569 | break; | - | ||||||||||||||||||
1570 | } | - | ||||||||||||||||||
1571 | endMacrostep(didChange); | - | ||||||||||||||||||
1572 | if (stopProcessingReason == Finished) | - | ||||||||||||||||||
1573 | exitInterpreter(); | - | ||||||||||||||||||
1574 | } | - | ||||||||||||||||||
1575 | - | |||||||||||||||||||
1576 | void QStateMachinePrivate::_q_startDelayedEventTimer(int id, int delay) | - | ||||||||||||||||||
1577 | { | - | ||||||||||||||||||
1578 | QStateMachine * const q = q_func(); | - | ||||||||||||||||||
1579 | QMutexLocker locker(&delayedEventsMutex); | - | ||||||||||||||||||
1580 | QHash<int, DelayedEvent>::iterator it = delayedEvents.find(id); | - | ||||||||||||||||||
1581 | if (it != delayedEvents.end()) { | - | ||||||||||||||||||
1582 | DelayedEvent &e = it.value(); | - | ||||||||||||||||||
1583 | ((!(!e.timerId)) ? qt_assert("!e.timerId",__FILE__,19491956) : qt_noop()); | - | ||||||||||||||||||
1584 | e.timerId = q->startTimer(delay); | - | ||||||||||||||||||
1585 | if (!e.timerId) { | - | ||||||||||||||||||
1586 | QMessageLogger(__FILE__, 19521959, __PRETTY_FUNCTION__).warning("QStateMachine::postDelayedEvent: failed to start timer (id=%d, delay=%d)", id, delay); | - | ||||||||||||||||||
1587 | delete e.event; | - | ||||||||||||||||||
1588 | delayedEvents.erase(it); | - | ||||||||||||||||||
1589 | delayedEventIdFreeList.release(id); | - | ||||||||||||||||||
1590 | } else { | - | ||||||||||||||||||
1591 | timerIdToDelayedEventId.insert(e.timerId, id); | - | ||||||||||||||||||
1592 | } | - | ||||||||||||||||||
1593 | } else { | - | ||||||||||||||||||
1594 | - | |||||||||||||||||||
1595 | delayedEventIdFreeList.release(id); | - | ||||||||||||||||||
1596 | } | - | ||||||||||||||||||
1597 | } | - | ||||||||||||||||||
1598 | - | |||||||||||||||||||
1599 | void QStateMachinePrivate::_q_killDelayedEventTimer(int id, int timerId) | - | ||||||||||||||||||
1600 | { | - | ||||||||||||||||||
1601 | QStateMachine * const q = q_func(); | - | ||||||||||||||||||
1602 | q->killTimer(timerId); | - | ||||||||||||||||||
1603 | QMutexLocker locker(&delayedEventsMutex); | - | ||||||||||||||||||
1604 | delayedEventIdFreeList.release(id); | - | ||||||||||||||||||
1605 | } | - | ||||||||||||||||||
1606 | - | |||||||||||||||||||
1607 | void QStateMachinePrivate::postInternalEvent(QEvent *e) | - | ||||||||||||||||||
1608 | { | - | ||||||||||||||||||
1609 | QMutexLocker locker(&internalEventMutex); | - | ||||||||||||||||||
1610 | internalEventQueue.append(e); | - | ||||||||||||||||||
1611 | } | - | ||||||||||||||||||
1612 | - | |||||||||||||||||||
1613 | void QStateMachinePrivate::postExternalEvent(QEvent *e) | - | ||||||||||||||||||
1614 | { | - | ||||||||||||||||||
1615 | QMutexLocker locker(&externalEventMutex); | - | ||||||||||||||||||
1616 | externalEventQueue.append(e); | - | ||||||||||||||||||
1617 | } | - | ||||||||||||||||||
1618 | - | |||||||||||||||||||
1619 | QEvent *QStateMachinePrivate::dequeueInternalEvent() | - | ||||||||||||||||||
1620 | { | - | ||||||||||||||||||
1621 | QMutexLocker locker(&internalEventMutex); | - | ||||||||||||||||||
1622 | if (internalEventQueue.isEmpty()) | - | ||||||||||||||||||
1623 | return 0; | - | ||||||||||||||||||
1624 | return internalEventQueue.takeFirst(); | - | ||||||||||||||||||
1625 | } | - | ||||||||||||||||||
1626 | - | |||||||||||||||||||
1627 | QEvent *QStateMachinePrivate::dequeueExternalEvent() | - | ||||||||||||||||||
1628 | { | - | ||||||||||||||||||
1629 | QMutexLocker locker(&externalEventMutex); | - | ||||||||||||||||||
1630 | if (externalEventQueue.isEmpty()) | - | ||||||||||||||||||
1631 | return 0; | - | ||||||||||||||||||
1632 | return externalEventQueue.takeFirst(); | - | ||||||||||||||||||
1633 | } | - | ||||||||||||||||||
1634 | - | |||||||||||||||||||
1635 | bool QStateMachinePrivate::isInternalEventQueueEmpty() | - | ||||||||||||||||||
1636 | { | - | ||||||||||||||||||
1637 | QMutexLocker locker(&internalEventMutex); | - | ||||||||||||||||||
1638 | return internalEventQueue.isEmpty(); | - | ||||||||||||||||||
1639 | } | - | ||||||||||||||||||
1640 | - | |||||||||||||||||||
1641 | bool QStateMachinePrivate::isExternalEventQueueEmpty() | - | ||||||||||||||||||
1642 | { | - | ||||||||||||||||||
1643 | QMutexLocker locker(&externalEventMutex); | - | ||||||||||||||||||
1644 | return externalEventQueue.isEmpty(); | - | ||||||||||||||||||
1645 | } | - | ||||||||||||||||||
1646 | - | |||||||||||||||||||
1647 | void QStateMachinePrivate::processEvents(EventProcessingMode processingMode) | - | ||||||||||||||||||
1648 | { | - | ||||||||||||||||||
1649 | QStateMachine * const q = q_func(); | - | ||||||||||||||||||
1650 | if ((state != Running) || processing || processingScheduled) | - | ||||||||||||||||||
1651 | return; | - | ||||||||||||||||||
1652 | switch (processingMode) { | - | ||||||||||||||||||
1653 | case DirectProcessing: | - | ||||||||||||||||||
1654 | if (QThread::currentThread() == q->thread()) { | - | ||||||||||||||||||
1655 | _q_process(); | - | ||||||||||||||||||
1656 | break; | - | ||||||||||||||||||
1657 | } | - | ||||||||||||||||||
1658 | case QueuedProcessing: | - | ||||||||||||||||||
1659 | processingScheduled = true; | - | ||||||||||||||||||
1660 | QMetaObject::invokeMethod(q, "_q_process", Qt::QueuedConnection); | - | ||||||||||||||||||
1661 | break; | - | ||||||||||||||||||
1662 | } | - | ||||||||||||||||||
1663 | } | - | ||||||||||||||||||
1664 | - | |||||||||||||||||||
1665 | void QStateMachinePrivate::cancelAllDelayedEvents() | - | ||||||||||||||||||
1666 | { | - | ||||||||||||||||||
1667 | QStateMachine * const q = q_func(); | - | ||||||||||||||||||
1668 | QMutexLocker locker(&delayedEventsMutex); | - | ||||||||||||||||||
1669 | QHash<int, DelayedEvent>::const_iterator it; | - | ||||||||||||||||||
1670 | for (it = delayedEvents.constBegin(); it != delayedEvents.constEnd(); ++it) { | - | ||||||||||||||||||
1671 | const DelayedEvent &e = it.value(); | - | ||||||||||||||||||
1672 | if (e.timerId) { | - | ||||||||||||||||||
1673 | timerIdToDelayedEventId.remove(e.timerId); | - | ||||||||||||||||||
1674 | q->killTimer(e.timerId); | - | ||||||||||||||||||
1675 | delayedEventIdFreeList.release(it.key()); | - | ||||||||||||||||||
1676 | } else { | - | ||||||||||||||||||
1677 | - | |||||||||||||||||||
1678 | } | - | ||||||||||||||||||
1679 | delete e.event; | - | ||||||||||||||||||
1680 | } | - | ||||||||||||||||||
1681 | delayedEvents.clear(); | - | ||||||||||||||||||
1682 | } | - | ||||||||||||||||||
1683 | - | |||||||||||||||||||
1684 | - | |||||||||||||||||||
1685 | - | |||||||||||||||||||
1686 | - | |||||||||||||||||||
1687 | - | |||||||||||||||||||
1688 | - | |||||||||||||||||||
1689 | - | |||||||||||||||||||
1690 | void QStateMachinePrivate::noMicrostep() | - | ||||||||||||||||||
1691 | { } | - | ||||||||||||||||||
1692 | void QStateMachinePrivate::processedPendingEvents(bool didChange) | - | ||||||||||||||||||
1693 | { | - | ||||||||||||||||||
1694 | (void)didChange;; | - | ||||||||||||||||||
1695 | } | - | ||||||||||||||||||
1696 | - | |||||||||||||||||||
1697 | void QStateMachinePrivate::beginMacrostep() | - | ||||||||||||||||||
1698 | { } | - | ||||||||||||||||||
1699 | - | |||||||||||||||||||
1700 | void QStateMachinePrivate::endMacrostep(bool didChange) | - | ||||||||||||||||||
1701 | { | - | ||||||||||||||||||
1702 | (void)didChange;; | - | ||||||||||||||||||
1703 | } | - | ||||||||||||||||||
1704 | - | |||||||||||||||||||
1705 | void QStateMachinePrivate::exitInterpreter() | - | ||||||||||||||||||
1706 | { | - | ||||||||||||||||||
1707 | } | - | ||||||||||||||||||
1708 | - | |||||||||||||||||||
1709 | void QStateMachinePrivate::emitStateFinished(QState *forState, QFinalState *guiltyState) | - | ||||||||||||||||||
1710 | { | - | ||||||||||||||||||
1711 | (void)guiltyState;; | - | ||||||||||||||||||
1712 | ((!(guiltyState)) ? qt_assert("guiltyState",__FILE__,20992106) : qt_noop()); | - | ||||||||||||||||||
1713 | - | |||||||||||||||||||
1714 | - | |||||||||||||||||||
1715 | - | |||||||||||||||||||
1716 | - | |||||||||||||||||||
1717 | - | |||||||||||||||||||
1718 | - | |||||||||||||||||||
1719 | QStatePrivate::get(forState)->emitFinished(); | - | ||||||||||||||||||
1720 | } | - | ||||||||||||||||||
1721 | - | |||||||||||||||||||
1722 | void QStateMachinePrivate::startupHook() | - | ||||||||||||||||||
1723 | { | - | ||||||||||||||||||
1724 | } | - | ||||||||||||||||||
1725 | - | |||||||||||||||||||
1726 | namespace _QStateMachine_Internal{ | - | ||||||||||||||||||
1727 | - | |||||||||||||||||||
1728 | class GoToStateTransition : public QAbstractTransition | - | ||||||||||||||||||
1729 | { | - | ||||||||||||||||||
1730 | public: template <typename ThisObject> inline void qt_check_for_QOBJECT_macro(const ThisObject &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; } | - | ||||||||||||||||||
1731 | #pragma GCC diagnostic push | - | ||||||||||||||||||
1732 | static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); | - | ||||||||||||||||||
1733 | #pragma GCC diagnostic pop | - | ||||||||||||||||||
1734 | struct QPrivateSignal {}; | - | ||||||||||||||||||
1735 | public: | - | ||||||||||||||||||
1736 | GoToStateTransition(QAbstractState *target) | - | ||||||||||||||||||
1737 | : QAbstractTransition() | - | ||||||||||||||||||
1738 | { setTargetState(target); } | - | ||||||||||||||||||
1739 | protected: | - | ||||||||||||||||||
1740 | void onTransition(QEvent *) override { deleteLater(); } | - | ||||||||||||||||||
1741 | bool eventTest(QEvent *) override { return true; } | - | ||||||||||||||||||
1742 | }; | - | ||||||||||||||||||
1743 | - | |||||||||||||||||||
1744 | } | - | ||||||||||||||||||
1745 | - | |||||||||||||||||||
1746 | - | |||||||||||||||||||
1747 | using namespace _QStateMachine_Internal; | - | ||||||||||||||||||
1748 | void QStateMachinePrivate::goToState(QAbstractState *targetState) | - | ||||||||||||||||||
1749 | { | - | ||||||||||||||||||
1750 | if (!targetState) { | - | ||||||||||||||||||
1751 | QMessageLogger(__FILE__, 21452152, __PRETTY_FUNCTION__).warning("QStateMachine::goToState(): cannot go to null state"); | - | ||||||||||||||||||
1752 | return; | - | ||||||||||||||||||
1753 | } | - | ||||||||||||||||||
1754 | - | |||||||||||||||||||
1755 | if (configuration.contains(targetState)) | - | ||||||||||||||||||
1756 | return; | - | ||||||||||||||||||
1757 | - | |||||||||||||||||||
1758 | ((!(state == Running)) ? qt_assert("state == Running",__FILE__,21522159) : qt_noop()); | - | ||||||||||||||||||
1759 | QState *sourceState = 0; | - | ||||||||||||||||||
1760 | QSet<QAbstractState*>::const_iterator it; | - | ||||||||||||||||||
1761 | for (it = configuration.constBegin(); it != configuration.constEnd(); ++it) { | - | ||||||||||||||||||
1762 | sourceState = toStandardState(*it); | - | ||||||||||||||||||
1763 | if (sourceState != 0) | - | ||||||||||||||||||
1764 | break; | - | ||||||||||||||||||
1765 | } | - | ||||||||||||||||||
1766 | - | |||||||||||||||||||
1767 | ((!(sourceState != 0)) ? qt_assert("sourceState != 0",__FILE__,21612168) : qt_noop()); | - | ||||||||||||||||||
1768 | - | |||||||||||||||||||
1769 | - | |||||||||||||||||||
1770 | GoToStateTransition *trans = sourceState->findChild<GoToStateTransition*>(); | - | ||||||||||||||||||
1771 | if (!trans) { | - | ||||||||||||||||||
1772 | trans = new GoToStateTransition(targetState); | - | ||||||||||||||||||
1773 | sourceState->addTransition(trans); | - | ||||||||||||||||||
1774 | } else { | - | ||||||||||||||||||
1775 | trans->setTargetState(targetState); | - | ||||||||||||||||||
1776 | } | - | ||||||||||||||||||
1777 | - | |||||||||||||||||||
1778 | processEvents(QueuedProcessing); | - | ||||||||||||||||||
1779 | } | - | ||||||||||||||||||
1780 | - | |||||||||||||||||||
1781 | void QStateMachinePrivate::registerTransitions(QAbstractState *state) | - | ||||||||||||||||||
1782 | { | - | ||||||||||||||||||
1783 | QState *group = toStandardState(state); | - | ||||||||||||||||||
1784 | if (!group) | - | ||||||||||||||||||
1785 | return; | - | ||||||||||||||||||
1786 | QList<QAbstractTransition*> transitions = QStatePrivate::get(group)->transitions(); | - | ||||||||||||||||||
1787 | for (int i = 0; i < transitions.size(); ++i) { | - | ||||||||||||||||||
1788 | QAbstractTransition *t = transitions.at(i); | - | ||||||||||||||||||
1789 | registerTransition(t); | - | ||||||||||||||||||
1790 | } | - | ||||||||||||||||||
1791 | } | - | ||||||||||||||||||
1792 | - | |||||||||||||||||||
1793 | void QStateMachinePrivate::maybeRegisterTransition(QAbstractTransition *transition) | - | ||||||||||||||||||
1794 | { | - | ||||||||||||||||||
1795 | if (QSignalTransition *st = qobject_cast<QSignalTransition*>(transition)) { | - | ||||||||||||||||||
1796 | maybeRegisterSignalTransition(st); | - | ||||||||||||||||||
1797 | } | - | ||||||||||||||||||
1798 | - | |||||||||||||||||||
1799 | else if (QEventTransition *et = qobject_cast<QEventTransition*>(transition)) { | - | ||||||||||||||||||
1800 | maybeRegisterEventTransition(et); | - | ||||||||||||||||||
1801 | } | - | ||||||||||||||||||
1802 | - | |||||||||||||||||||
1803 | } | - | ||||||||||||||||||
1804 | - | |||||||||||||||||||
1805 | void QStateMachinePrivate::registerTransition(QAbstractTransition *transition) | - | ||||||||||||||||||
1806 | { | - | ||||||||||||||||||
1807 | if (QSignalTransition *st = qobject_cast<QSignalTransition*>(transition)) { | - | ||||||||||||||||||
1808 | registerSignalTransition(st); | - | ||||||||||||||||||
1809 | } | - | ||||||||||||||||||
1810 | - | |||||||||||||||||||
1811 | else if (QEventTransition *oet = qobject_cast<QEventTransition*>(transition)) { | - | ||||||||||||||||||
1812 | registerEventTransition(oet); | - | ||||||||||||||||||
1813 | } | - | ||||||||||||||||||
1814 | - | |||||||||||||||||||
1815 | } | - | ||||||||||||||||||
1816 | - | |||||||||||||||||||
1817 | void QStateMachinePrivate::unregisterTransition(QAbstractTransition *transition) | - | ||||||||||||||||||
1818 | { | - | ||||||||||||||||||
1819 | if (QSignalTransition *st = qobject_cast<QSignalTransition*>(transition)) { | - | ||||||||||||||||||
1820 | unregisterSignalTransition(st); | - | ||||||||||||||||||
1821 | } | - | ||||||||||||||||||
1822 | - | |||||||||||||||||||
1823 | else if (QEventTransition *oet = qobject_cast<QEventTransition*>(transition)) { | - | ||||||||||||||||||
1824 | unregisterEventTransition(oet); | - | ||||||||||||||||||
1825 | } | - | ||||||||||||||||||
1826 | - | |||||||||||||||||||
1827 | } | - | ||||||||||||||||||
1828 | - | |||||||||||||||||||
1829 | void QStateMachinePrivate::maybeRegisterSignalTransition(QSignalTransition *transition) | - | ||||||||||||||||||
1830 | { | - | ||||||||||||||||||
1831 | QStateMachine * const q = q_func(); | - | ||||||||||||||||||
1832 | if ((state == Running) && (configuration.contains(transition->sourceState()) | - | ||||||||||||||||||
1833 | || (transition->senderObject() && (transition->senderObject()->thread() != q->thread())))) { | - | ||||||||||||||||||
1834 | registerSignalTransition(transition); | - | ||||||||||||||||||
1835 | } | - | ||||||||||||||||||
1836 | } | - | ||||||||||||||||||
1837 | - | |||||||||||||||||||
1838 | void QStateMachinePrivate::registerSignalTransition(QSignalTransition *transition) | - | ||||||||||||||||||
1839 | { | - | ||||||||||||||||||
1840 | QStateMachine * const q = q_func(); | - | ||||||||||||||||||
1841 | if (QSignalTransitionPrivate::get(transition)->signalIndex != -1) | - | ||||||||||||||||||
1842 | return; | - | ||||||||||||||||||
1843 | const QObject *sender = QSignalTransitionPrivate::get(transition)->sender; | - | ||||||||||||||||||
1844 | if (!sender) | - | ||||||||||||||||||
1845 | return; | - | ||||||||||||||||||
1846 | QByteArray signal = QSignalTransitionPrivate::get(transition)->signal; | - | ||||||||||||||||||
1847 | if (signal.isEmpty()) | - | ||||||||||||||||||
1848 | return; | - | ||||||||||||||||||
1849 | if (signal.startsWith('0'+2)) | - | ||||||||||||||||||
1850 | signal.remove(0, 1); | - | ||||||||||||||||||
1851 | const QMetaObject *meta = sender->metaObject(); | - | ||||||||||||||||||
1852 | int signalIndex = meta->indexOfSignal(signal); | - | ||||||||||||||||||
1853 | int originalSignalIndex = signalIndex; | - | ||||||||||||||||||
1854 | if (signalIndex == -1) { | - | ||||||||||||||||||
1855 | signalIndex = meta->indexOfSignal(QMetaObject::normalizedSignature(signal)); | - | ||||||||||||||||||
1856 | if (signalIndex == -1) { | - | ||||||||||||||||||
1857 | QMessageLogger(__FILE__, 22512258, __PRETTY_FUNCTION__).warning("QSignalTransition: no such signal: %s::%s", | - | ||||||||||||||||||
1858 | meta->className(), signal.constData()); | - | ||||||||||||||||||
1859 | return; | - | ||||||||||||||||||
1860 | } | - | ||||||||||||||||||
1861 | originalSignalIndex = signalIndex; | - | ||||||||||||||||||
1862 | } | - | ||||||||||||||||||
1863 | - | |||||||||||||||||||
1864 | - | |||||||||||||||||||
1865 | while (meta->method(signalIndex).attributes() & QMetaMethod::Cloned) | - | ||||||||||||||||||
1866 | --signalIndex; | - | ||||||||||||||||||
1867 | - | |||||||||||||||||||
1868 | connectionsMutex.lock(); | - | ||||||||||||||||||
1869 | QVector<int> &connectedSignalIndexes = connections[sender]; | - | ||||||||||||||||||
1870 | if (connectedSignalIndexes.size() <= signalIndex) | - | ||||||||||||||||||
1871 | connectedSignalIndexes.resize(signalIndex+1); | - | ||||||||||||||||||
1872 | if (connectedSignalIndexes.at(signalIndex) == 0) { | - | ||||||||||||||||||
1873 | if (!signalEventGenerator) | - | ||||||||||||||||||
1874 | signalEventGenerator = new QSignalEventGenerator(q); | - | ||||||||||||||||||
1875 | static const int generatorMethodOffset = QSignalEventGenerator::staticMetaObject.methodOffset(); | - | ||||||||||||||||||
1876 | bool ok = QMetaObject::connect(sender, signalIndex, signalEventGenerator, generatorMethodOffset); | - | ||||||||||||||||||
1877 | if (!ok) { | - | ||||||||||||||||||
1878 | - | |||||||||||||||||||
1879 | - | |||||||||||||||||||
1880 | - | |||||||||||||||||||
1881 | - | |||||||||||||||||||
1882 | - | |||||||||||||||||||
1883 | return; | - | ||||||||||||||||||
1884 | } | - | ||||||||||||||||||
1885 | } | - | ||||||||||||||||||
1886 | ++connectedSignalIndexes[signalIndex]; | - | ||||||||||||||||||
1887 | connectionsMutex.unlock(); | - | ||||||||||||||||||
1888 | - | |||||||||||||||||||
1889 | QSignalTransitionPrivate::get(transition)->signalIndex = signalIndex; | - | ||||||||||||||||||
1890 | QSignalTransitionPrivate::get(transition)->originalSignalIndex = originalSignalIndex; | - | ||||||||||||||||||
1891 | - | |||||||||||||||||||
1892 | - | |||||||||||||||||||
1893 | - | |||||||||||||||||||
1894 | - | |||||||||||||||||||
1895 | - | |||||||||||||||||||
1896 | } | - | ||||||||||||||||||
1897 | - | |||||||||||||||||||
1898 | void QStateMachinePrivate::unregisterSignalTransition(QSignalTransition *transition) | - | ||||||||||||||||||
1899 | { | - | ||||||||||||||||||
1900 | int signalIndex = QSignalTransitionPrivate::get(transition)->signalIndex; | - | ||||||||||||||||||
1901 | if (signalIndex == -1) | - | ||||||||||||||||||
1902 | return; | - | ||||||||||||||||||
1903 | const QObject *sender = QSignalTransitionPrivate::get(transition)->sender; | - | ||||||||||||||||||
1904 | QSignalTransitionPrivate::get(transition)->signalIndex = -1; | - | ||||||||||||||||||
1905 | - | |||||||||||||||||||
1906 | connectionsMutex.lock(); | - | ||||||||||||||||||
1907 | QVector<int> &connectedSignalIndexes = connections[sender]; | - | ||||||||||||||||||
1908 | ((!(connectedSignalIndexes.size() > signalIndex)) ? qt_assert("connectedSignalIndexes.size() > signalIndex",__FILE__,23022309) : qt_noop()); | - | ||||||||||||||||||
1909 | ((!(connectedSignalIndexes.at(signalIndex) != 0)) ? qt_assert("connectedSignalIndexes.at(signalIndex) != 0",__FILE__,23032310) : qt_noop()); | - | ||||||||||||||||||
1910 | if (--connectedSignalIndexes[signalIndex] == 0) { | - | ||||||||||||||||||
1911 | ((!(signalEventGenerator != 0)) ? qt_assert("signalEventGenerator != 0",__FILE__,23052312) : qt_noop()); | - | ||||||||||||||||||
1912 | static const int generatorMethodOffset = QSignalEventGenerator::staticMetaObject.methodOffset(); | - | ||||||||||||||||||
1913 | QMetaObject::disconnect(sender, signalIndex, signalEventGenerator, generatorMethodOffset); | - | ||||||||||||||||||
1914 | int sum = 0; | - | ||||||||||||||||||
1915 | for (int i = 0; i < connectedSignalIndexes.size(); ++i) | - | ||||||||||||||||||
1916 | sum += connectedSignalIndexes.at(i); | - | ||||||||||||||||||
1917 | if (sum == 0) | - | ||||||||||||||||||
1918 | connections.remove(sender); | - | ||||||||||||||||||
1919 | } | - | ||||||||||||||||||
1920 | connectionsMutex.unlock(); | - | ||||||||||||||||||
1921 | } | - | ||||||||||||||||||
1922 | - | |||||||||||||||||||
1923 | void QStateMachinePrivate::unregisterAllTransitions() | - | ||||||||||||||||||
1924 | { | - | ||||||||||||||||||
1925 | QStateMachine * const q = q_func(); | - | ||||||||||||||||||
1926 | { | - | ||||||||||||||||||
1927 | QList<QSignalTransition*> transitions = rootState()->findChildren<QSignalTransition*>(); | - | ||||||||||||||||||
1928 | for (int i = 0; i < transitions.size(); ++i) { | - | ||||||||||||||||||
1929 | QSignalTransition *t = transitions.at(i); | - | ||||||||||||||||||
1930 | if (t->machine() == q) | - | ||||||||||||||||||
1931 | unregisterSignalTransition(t); | - | ||||||||||||||||||
1932 | } | - | ||||||||||||||||||
1933 | } | - | ||||||||||||||||||
1934 | { | - | ||||||||||||||||||
1935 | QList<QEventTransition*> transitions = rootState()->findChildren<QEventTransition*>(); | - | ||||||||||||||||||
1936 | for (int i = 0; i < transitions.size(); ++i) { | - | ||||||||||||||||||
1937 | QEventTransition *t = transitions.at(i); | - | ||||||||||||||||||
1938 | if (t->machine() == q) | - | ||||||||||||||||||
1939 | unregisterEventTransition(t); | - | ||||||||||||||||||
1940 | } | - | ||||||||||||||||||
1941 | } | - | ||||||||||||||||||
1942 | } | - | ||||||||||||||||||
1943 | - | |||||||||||||||||||
1944 | - | |||||||||||||||||||
1945 | void QStateMachinePrivate::maybeRegisterEventTransition(QEventTransition *transition) | - | ||||||||||||||||||
1946 | { | - | ||||||||||||||||||
1947 | if ((state == Running) && configuration.contains(transition->sourceState())) | - | ||||||||||||||||||
1948 | registerEventTransition(transition); | - | ||||||||||||||||||
1949 | } | - | ||||||||||||||||||
1950 | - | |||||||||||||||||||
1951 | void QStateMachinePrivate::registerEventTransition(QEventTransition *transition) | - | ||||||||||||||||||
1952 | { | - | ||||||||||||||||||
1953 | QStateMachine * const q = q_func(); | - | ||||||||||||||||||
1954 | if (QEventTransitionPrivate::get(transition)->registered) | - | ||||||||||||||||||
1955 | return; | - | ||||||||||||||||||
1956 | if (transition->eventType() >= QEvent::User) { | - | ||||||||||||||||||
1957 | QMessageLogger(__FILE__, 23512358, __PRETTY_FUNCTION__).warning("QObject event transitions are not supported for custom types"); | - | ||||||||||||||||||
1958 | return; | - | ||||||||||||||||||
1959 | } | - | ||||||||||||||||||
1960 | QObject *object = QEventTransitionPrivate::get(transition)->object; | - | ||||||||||||||||||
1961 | if (!object) | - | ||||||||||||||||||
1962 | return; | - | ||||||||||||||||||
1963 | QObjectPrivate *od = QObjectPrivate::get(object); | - | ||||||||||||||||||
1964 | if (!od->extraData || !od->extraData->eventFilters.contains(q)) | - | ||||||||||||||||||
1965 | object->installEventFilter(q); | - | ||||||||||||||||||
1966 | ++qobjectEvents[object][transition->eventType()]; | - | ||||||||||||||||||
1967 | QEventTransitionPrivate::get(transition)->registered = true; | - | ||||||||||||||||||
1968 | - | |||||||||||||||||||
1969 | - | |||||||||||||||||||
1970 | - | |||||||||||||||||||
1971 | - | |||||||||||||||||||
1972 | - | |||||||||||||||||||
1973 | } | - | ||||||||||||||||||
1974 | - | |||||||||||||||||||
1975 | void QStateMachinePrivate::unregisterEventTransition(QEventTransition *transition) | - | ||||||||||||||||||
1976 | { | - | ||||||||||||||||||
1977 | QStateMachine * const q = q_func(); | - | ||||||||||||||||||
1978 | if (!QEventTransitionPrivate::get(transition)->registered) | - | ||||||||||||||||||
1979 | return; | - | ||||||||||||||||||
1980 | QObject *object = QEventTransitionPrivate::get(transition)->object; | - | ||||||||||||||||||
1981 | QHash<QEvent::Type, int> &events = qobjectEvents[object]; | - | ||||||||||||||||||
1982 | ((!(events.value(transition->eventType()) > 0)) ? qt_assert("events.value(transition->eventType()) > 0",__FILE__,23762383) : qt_noop()); | - | ||||||||||||||||||
1983 | if (--events[transition->eventType()] == 0) { | - | ||||||||||||||||||
1984 | events.remove(transition->eventType()); | - | ||||||||||||||||||
1985 | int sum = 0; | - | ||||||||||||||||||
1986 | QHash<QEvent::Type, int>::const_iterator it; | - | ||||||||||||||||||
1987 | for (it = events.constBegin(); it != events.constEnd(); ++it) | - | ||||||||||||||||||
1988 | sum += it.value(); | - | ||||||||||||||||||
1989 | if (sum == 0) { | - | ||||||||||||||||||
1990 | qobjectEvents.remove(object); | - | ||||||||||||||||||
1991 | object->removeEventFilter(q); | - | ||||||||||||||||||
1992 | } | - | ||||||||||||||||||
1993 | } | - | ||||||||||||||||||
1994 | QEventTransitionPrivate::get(transition)->registered = false; | - | ||||||||||||||||||
1995 | } | - | ||||||||||||||||||
1996 | - | |||||||||||||||||||
1997 | void QStateMachinePrivate::handleFilteredEvent(QObject *watched, QEvent *event) | - | ||||||||||||||||||
1998 | { | - | ||||||||||||||||||
1999 | if (qobjectEvents.value(watched).contains(event->type())) { | - | ||||||||||||||||||
2000 | postInternalEvent(new QStateMachine::WrappedEvent(watched, handler->cloneEvent(event))); | - | ||||||||||||||||||
2001 | processEvents(DirectProcessing); | - | ||||||||||||||||||
2002 | } | - | ||||||||||||||||||
2003 | } | - | ||||||||||||||||||
2004 | - | |||||||||||||||||||
2005 | - | |||||||||||||||||||
2006 | void QStateMachinePrivate::handleTransitionSignal(QObject *sender, int signalIndex, | - | ||||||||||||||||||
2007 | void **argv) | - | ||||||||||||||||||
2008 | { | - | ||||||||||||||||||
2009 | - | |||||||||||||||||||
2010 | connectionsMutex.lock(); | - | ||||||||||||||||||
2011 | ((!(connections[sender].at(signalIndex) != 0)) ? qt_assert("connections[sender].at(signalIndex) != 0",__FILE__,24052412) : qt_noop()); | - | ||||||||||||||||||
2012 | connectionsMutex.unlock(); | - | ||||||||||||||||||
2013 | - | |||||||||||||||||||
2014 | const QMetaObject *meta = sender->metaObject(); | - | ||||||||||||||||||
2015 | QMetaMethod method = meta->method(signalIndex); | - | ||||||||||||||||||
2016 | int argc = method.parameterCount(); | - | ||||||||||||||||||
2017 | QList<QVariant> vargs; | - | ||||||||||||||||||
2018 | vargs.reserve(argc); | - | ||||||||||||||||||
2019 | for (int i = 0; i < argc; ++i) { | - | ||||||||||||||||||
2020 | int type = method.parameterType(i); | - | ||||||||||||||||||
2021 | vargs.append(QVariant(type, argv[i+1])); | - | ||||||||||||||||||
2022 | } | - | ||||||||||||||||||
2023 | - | |||||||||||||||||||
2024 | - | |||||||||||||||||||
2025 | - | |||||||||||||||||||
2026 | - | |||||||||||||||||||
2027 | - | |||||||||||||||||||
2028 | postInternalEvent(new QStateMachine::SignalEvent(sender, signalIndex, vargs)); | - | ||||||||||||||||||
2029 | processEvents(DirectProcessing); | - | ||||||||||||||||||
2030 | } | - | ||||||||||||||||||
2031 | - | |||||||||||||||||||
2032 | - | |||||||||||||||||||
2033 | - | |||||||||||||||||||
2034 | - | |||||||||||||||||||
2035 | QStateMachine::QStateMachine(QObject *parent) | - | ||||||||||||||||||
2036 | : QState(*new QStateMachinePrivate, 0) | - | ||||||||||||||||||
2037 | { | - | ||||||||||||||||||
2038 | - | |||||||||||||||||||
2039 | - | |||||||||||||||||||
2040 | setParent(parent); | - | ||||||||||||||||||
2041 | } | - | ||||||||||||||||||
2042 | - | |||||||||||||||||||
2043 | - | |||||||||||||||||||
2044 | - | |||||||||||||||||||
2045 | - | |||||||||||||||||||
2046 | - | |||||||||||||||||||
2047 | - | |||||||||||||||||||
2048 | - | |||||||||||||||||||
2049 | QStateMachine::QStateMachine(QState::ChildMode childMode, QObject *parent) | - | ||||||||||||||||||
2050 | : QState(*new QStateMachinePrivate, 0) | - | ||||||||||||||||||
2051 | { | - | ||||||||||||||||||
2052 | QStateMachinePrivate * const d = d_func(); | - | ||||||||||||||||||
2053 | d->childMode = childMode; | - | ||||||||||||||||||
2054 | setParent(parent); | - | ||||||||||||||||||
2055 | } | - | ||||||||||||||||||
2056 | - | |||||||||||||||||||
2057 | - | |||||||||||||||||||
2058 | - | |||||||||||||||||||
2059 | - | |||||||||||||||||||
2060 | QStateMachine::QStateMachine(QStateMachinePrivate &dd, QObject *parent) | - | ||||||||||||||||||
2061 | : QState(dd, 0) | - | ||||||||||||||||||
2062 | { | - | ||||||||||||||||||
2063 | setParent(parent); | - | ||||||||||||||||||
2064 | } | - | ||||||||||||||||||
2065 | - | |||||||||||||||||||
2066 | - | |||||||||||||||||||
2067 | - | |||||||||||||||||||
2068 | - | |||||||||||||||||||
2069 | QStateMachine::~QStateMachine() | - | ||||||||||||||||||
2070 | { | - | ||||||||||||||||||
2071 | } | - | ||||||||||||||||||
2072 | QStateMachine::Error QStateMachine::error() const | - | ||||||||||||||||||
2073 | { | - | ||||||||||||||||||
2074 | const QStateMachinePrivate * const d = d_func(); | - | ||||||||||||||||||
2075 | return d->error; | - | ||||||||||||||||||
2076 | } | - | ||||||||||||||||||
2077 | - | |||||||||||||||||||
2078 | - | |||||||||||||||||||
2079 | - | |||||||||||||||||||
2080 | - | |||||||||||||||||||
2081 | QString QStateMachine::errorString() const | - | ||||||||||||||||||
2082 | { | - | ||||||||||||||||||
2083 | const QStateMachinePrivate * const d = d_func(); | - | ||||||||||||||||||
2084 | return d->errorString; | - | ||||||||||||||||||
2085 | } | - | ||||||||||||||||||
2086 | - | |||||||||||||||||||
2087 | - | |||||||||||||||||||
2088 | - | |||||||||||||||||||
2089 | - | |||||||||||||||||||
2090 | void QStateMachine::clearError() | - | ||||||||||||||||||
2091 | { | - | ||||||||||||||||||
2092 | QStateMachinePrivate * const d = d_func(); | - | ||||||||||||||||||
2093 | d->errorString.clear(); | - | ||||||||||||||||||
2094 | d->error = NoError; | - | ||||||||||||||||||
2095 | } | - | ||||||||||||||||||
2096 | - | |||||||||||||||||||
2097 | - | |||||||||||||||||||
2098 | - | |||||||||||||||||||
2099 | - | |||||||||||||||||||
2100 | - | |||||||||||||||||||
2101 | - | |||||||||||||||||||
2102 | QState::RestorePolicy QStateMachine::globalRestorePolicy() const | - | ||||||||||||||||||
2103 | { | - | ||||||||||||||||||
2104 | const QStateMachinePrivate * const d = d_func(); | - | ||||||||||||||||||
2105 | return d->globalRestorePolicy; | - | ||||||||||||||||||
2106 | } | - | ||||||||||||||||||
2107 | - | |||||||||||||||||||
2108 | - | |||||||||||||||||||
2109 | - | |||||||||||||||||||
2110 | - | |||||||||||||||||||
2111 | - | |||||||||||||||||||
2112 | - | |||||||||||||||||||
2113 | - | |||||||||||||||||||
2114 | void QStateMachine::setGlobalRestorePolicy(QState::RestorePolicy restorePolicy) | - | ||||||||||||||||||
2115 | { | - | ||||||||||||||||||
2116 | QStateMachinePrivate * const d = d_func(); | - | ||||||||||||||||||
2117 | d->globalRestorePolicy = restorePolicy; | - | ||||||||||||||||||
2118 | } | - | ||||||||||||||||||
2119 | void QStateMachine::addState(QAbstractState *state) | - | ||||||||||||||||||
2120 | { | - | ||||||||||||||||||
2121 | if (!state) { | - | ||||||||||||||||||
2122 | QMessageLogger(__FILE__, 25652572, __PRETTY_FUNCTION__).warning("QStateMachine::addState: cannot add null state"); | - | ||||||||||||||||||
2123 | return; | - | ||||||||||||||||||
2124 | } | - | ||||||||||||||||||
2125 | if (QAbstractStatePrivate::get(state)->machine() == this) { | - | ||||||||||||||||||
2126 | QMessageLogger(__FILE__, 25692576, __PRETTY_FUNCTION__).warning("QStateMachine::addState: state has already been added to this machine"); | - | ||||||||||||||||||
2127 | return; | - | ||||||||||||||||||
2128 | } | - | ||||||||||||||||||
2129 | state->setParent(this); | - | ||||||||||||||||||
2130 | } | - | ||||||||||||||||||
2131 | - | |||||||||||||||||||
2132 | - | |||||||||||||||||||
2133 | - | |||||||||||||||||||
2134 | - | |||||||||||||||||||
2135 | - | |||||||||||||||||||
2136 | - | |||||||||||||||||||
2137 | - | |||||||||||||||||||
2138 | void QStateMachine::removeState(QAbstractState *state) | - | ||||||||||||||||||
2139 | { | - | ||||||||||||||||||
2140 | if (!state) { | - | ||||||||||||||||||
2141 | QMessageLogger(__FILE__, 25842591, __PRETTY_FUNCTION__).warning("QStateMachine::removeState: cannot remove null state"); | - | ||||||||||||||||||
2142 | return; | - | ||||||||||||||||||
2143 | } | - | ||||||||||||||||||
2144 | if (QAbstractStatePrivate::get(state)->machine() != this) { | - | ||||||||||||||||||
2145 | QMessageLogger(__FILE__, 25882595, __PRETTY_FUNCTION__).warning("QStateMachine::removeState: state %p's machine (%p)" | - | ||||||||||||||||||
2146 | " is different from this machine (%p)", | - | ||||||||||||||||||
2147 | state, QAbstractStatePrivate::get(state)->machine(), this); | - | ||||||||||||||||||
2148 | return; | - | ||||||||||||||||||
2149 | } | - | ||||||||||||||||||
2150 | state->setParent(0); | - | ||||||||||||||||||
2151 | } | - | ||||||||||||||||||
2152 | - | |||||||||||||||||||
2153 | bool QStateMachine::isRunning() const | - | ||||||||||||||||||
2154 | { | - | ||||||||||||||||||
2155 | const QStateMachinePrivate * const d = d_func(); | - | ||||||||||||||||||
2156 | return (d->state == QStateMachinePrivate::Running); | - | ||||||||||||||||||
2157 | } | - | ||||||||||||||||||
2158 | void QStateMachine::start() | - | ||||||||||||||||||
2159 | { | - | ||||||||||||||||||
2160 | QStateMachinePrivate * const d = d_func(); | - | ||||||||||||||||||
2161 | - | |||||||||||||||||||
2162 | if ((childMode() == QState::ExclusiveStates) && (initialState() == 0)) { | - | ||||||||||||||||||
2163 | QMessageLogger(__FILE__, 26182625, __PRETTY_FUNCTION__).warning("QStateMachine::start: No initial state set for machine. Refusing to start."); | - | ||||||||||||||||||
2164 | return; | - | ||||||||||||||||||
2165 | } | - | ||||||||||||||||||
2166 | - | |||||||||||||||||||
2167 | switch (d->state) { | - | ||||||||||||||||||
2168 | case QStateMachinePrivate::NotRunning: | - | ||||||||||||||||||
2169 | d->state = QStateMachinePrivate::Starting; | - | ||||||||||||||||||
2170 | QMetaObject::invokeMethod(this, "_q_start", Qt::QueuedConnection); | - | ||||||||||||||||||
2171 | break; | - | ||||||||||||||||||
2172 | case QStateMachinePrivate::Starting: | - | ||||||||||||||||||
2173 | break; | - | ||||||||||||||||||
2174 | case QStateMachinePrivate::Running: | - | ||||||||||||||||||
2175 | QMessageLogger(__FILE__, 26302637, __PRETTY_FUNCTION__).warning("QStateMachine::start(): already running"); | - | ||||||||||||||||||
2176 | break; | - | ||||||||||||||||||
2177 | } | - | ||||||||||||||||||
2178 | } | - | ||||||||||||||||||
2179 | - | |||||||||||||||||||
2180 | - | |||||||||||||||||||
2181 | - | |||||||||||||||||||
2182 | - | |||||||||||||||||||
2183 | - | |||||||||||||||||||
2184 | - | |||||||||||||||||||
2185 | - | |||||||||||||||||||
2186 | void QStateMachine::stop() | - | ||||||||||||||||||
2187 | { | - | ||||||||||||||||||
2188 | QStateMachinePrivate * const d = d_func(); | - | ||||||||||||||||||
2189 | switch (d->state) { | - | ||||||||||||||||||
2190 | case QStateMachinePrivate::NotRunning: | - | ||||||||||||||||||
2191 | break; | - | ||||||||||||||||||
2192 | case QStateMachinePrivate::Starting: | - | ||||||||||||||||||
2193 | - | |||||||||||||||||||
2194 | d->stop = true; | - | ||||||||||||||||||
2195 | break; | - | ||||||||||||||||||
2196 | case QStateMachinePrivate::Running: | - | ||||||||||||||||||
2197 | d->stop = true; | - | ||||||||||||||||||
2198 | d->processEvents(QStateMachinePrivate::QueuedProcessing); | - | ||||||||||||||||||
2199 | break; | - | ||||||||||||||||||
2200 | } | - | ||||||||||||||||||
2201 | } | - | ||||||||||||||||||
2202 | - | |||||||||||||||||||
2203 | void QStateMachine::setRunning(bool running) | - | ||||||||||||||||||
2204 | { | - | ||||||||||||||||||
2205 | if (running) | - | ||||||||||||||||||
2206 | start(); | - | ||||||||||||||||||
2207 | else | - | ||||||||||||||||||
2208 | stop(); | - | ||||||||||||||||||
2209 | } | - | ||||||||||||||||||
2210 | void QStateMachine::postEvent(QEvent *event, EventPriority priority) | - | ||||||||||||||||||
2211 | { | - | ||||||||||||||||||
2212 | QStateMachinePrivate * const d = d_func(); | - | ||||||||||||||||||
2213 | switch (d->state) { | - | ||||||||||||||||||
2214 | case QStateMachinePrivate::Running: | - | ||||||||||||||||||
2215 | case QStateMachinePrivate::Starting: | - | ||||||||||||||||||
2216 | break; | - | ||||||||||||||||||
2217 | default: | - | ||||||||||||||||||
2218 | QMessageLogger(__FILE__, 26882695, __PRETTY_FUNCTION__).warning("QStateMachine::postEvent: cannot post event when the state machine is not running"); | - | ||||||||||||||||||
2219 | return; | - | ||||||||||||||||||
2220 | } | - | ||||||||||||||||||
2221 | if (!event) { | - | ||||||||||||||||||
2222 | QMessageLogger(__FILE__, 26922699, __PRETTY_FUNCTION__).warning("QStateMachine::postEvent: cannot post null event"); | - | ||||||||||||||||||
2223 | return; | - | ||||||||||||||||||
2224 | } | - | ||||||||||||||||||
2225 | - | |||||||||||||||||||
2226 | - | |||||||||||||||||||
2227 | - | |||||||||||||||||||
2228 | switch (priority) { | - | ||||||||||||||||||
2229 | case NormalPriority: | - | ||||||||||||||||||
2230 | d->postExternalEvent(event); | - | ||||||||||||||||||
2231 | break; | - | ||||||||||||||||||
2232 | case HighPriority: | - | ||||||||||||||||||
2233 | d->postInternalEvent(event); | - | ||||||||||||||||||
2234 | break; | - | ||||||||||||||||||
2235 | } | - | ||||||||||||||||||
2236 | d->processEvents(QStateMachinePrivate::QueuedProcessing); | - | ||||||||||||||||||
2237 | } | - | ||||||||||||||||||
2238 | int QStateMachine::postDelayedEvent(QEvent *event, int delay) | - | ||||||||||||||||||
2239 | { | - | ||||||||||||||||||
2240 | QStateMachinePrivate * const d = d_func(); | - | ||||||||||||||||||
2241 | if (d->state != QStateMachinePrivate::Running) { | - | ||||||||||||||||||
2242 | QMessageLogger(__FILE__, 27292736, __PRETTY_FUNCTION__).warning("QStateMachine::postDelayedEvent: cannot post event when the state machine is not running"); | - | ||||||||||||||||||
2243 | return -1; | - | ||||||||||||||||||
2244 | } | - | ||||||||||||||||||
2245 | if (!event) { | - | ||||||||||||||||||
2246 | QMessageLogger(__FILE__, 27332740, __PRETTY_FUNCTION__).warning("QStateMachine::postDelayedEvent: cannot post null event"); | - | ||||||||||||||||||
2247 | return -1; | - | ||||||||||||||||||
2248 | } | - | ||||||||||||||||||
2249 | if (delay < 0) { | - | ||||||||||||||||||
2250 | QMessageLogger(__FILE__, 27372744, __PRETTY_FUNCTION__).warning("QStateMachine::postDelayedEvent: delay cannot be negative"); | - | ||||||||||||||||||
2251 | return -1; | - | ||||||||||||||||||
2252 | } | - | ||||||||||||||||||
2253 | - | |||||||||||||||||||
2254 | - | |||||||||||||||||||
2255 | - | |||||||||||||||||||
2256 | QMutexLocker locker(&d->delayedEventsMutex); | - | ||||||||||||||||||
2257 | int id = d->delayedEventIdFreeList.next(); | - | ||||||||||||||||||
2258 | bool inMachineThread = (QThread::currentThread() == thread()); | - | ||||||||||||||||||
2259 | int timerId = inMachineThread ? startTimer(delay) : 0; | - | ||||||||||||||||||
2260 | if (inMachineThread && !timerId) { | - | ||||||||||||||||||
2261 | QMessageLogger(__FILE__, 27482755, __PRETTY_FUNCTION__).warning("QStateMachine::postDelayedEvent: failed to start timer with interval %d", delay); | - | ||||||||||||||||||
2262 | d->delayedEventIdFreeList.release(id); | - | ||||||||||||||||||
2263 | return -1; | - | ||||||||||||||||||
2264 | } | - | ||||||||||||||||||
2265 | QStateMachinePrivate::DelayedEvent delayedEvent(event, timerId); | - | ||||||||||||||||||
2266 | d->delayedEvents.insert(id, delayedEvent); | - | ||||||||||||||||||
2267 | if (timerId) { | - | ||||||||||||||||||
2268 | d->timerIdToDelayedEventId.insert(timerId, id); | - | ||||||||||||||||||
2269 | } else { | - | ||||||||||||||||||
2270 | ((!(!inMachineThread)) ? qt_assert("!inMachineThread",__FILE__,27572764) : qt_noop()); | - | ||||||||||||||||||
2271 | QMetaObject::invokeMethod(this, "_q_startDelayedEventTimer", | - | ||||||||||||||||||
2272 | Qt::QueuedConnection, | - | ||||||||||||||||||
2273 | QArgument<int >("int", id), | - | ||||||||||||||||||
2274 | QArgument<int >("int", delay)); | - | ||||||||||||||||||
2275 | } | - | ||||||||||||||||||
2276 | return id; | - | ||||||||||||||||||
2277 | } | - | ||||||||||||||||||
2278 | bool QStateMachine::cancelDelayedEvent(int id) | - | ||||||||||||||||||
2279 | { | - | ||||||||||||||||||
2280 | QStateMachinePrivate * const d = d_func(); | - | ||||||||||||||||||
2281 | if (d->state != QStateMachinePrivate::Running) { | - | ||||||||||||||||||
2282 | QMessageLogger(__FILE__, 27792786, __PRETTY_FUNCTION__).warning("QStateMachine::cancelDelayedEvent: the machine is not running"); | - | ||||||||||||||||||
2283 | return false; | - | ||||||||||||||||||
2284 | } | - | ||||||||||||||||||
2285 | QMutexLocker locker(&d->delayedEventsMutex); | - | ||||||||||||||||||
2286 | QStateMachinePrivate::DelayedEvent e = d->delayedEvents.take(id); | - | ||||||||||||||||||
2287 | if (!e.event) | - | ||||||||||||||||||
2288 | return false; | - | ||||||||||||||||||
2289 | if (e.timerId) { | - | ||||||||||||||||||
2290 | d->timerIdToDelayedEventId.remove(e.timerId); | - | ||||||||||||||||||
2291 | bool inMachineThread = (QThread::currentThread() == thread()); | - | ||||||||||||||||||
2292 | if (inMachineThread) { | - | ||||||||||||||||||
2293 | killTimer(e.timerId); | - | ||||||||||||||||||
2294 | d->delayedEventIdFreeList.release(id); | - | ||||||||||||||||||
2295 | } else { | - | ||||||||||||||||||
2296 | QMetaObject::invokeMethod(this, "_q_killDelayedEventTimer", | - | ||||||||||||||||||
2297 | Qt::QueuedConnection, | - | ||||||||||||||||||
2298 | QArgument<int >("int", id), | - | ||||||||||||||||||
2299 | QArgument<int >("int", e.timerId)); | - | ||||||||||||||||||
2300 | } | - | ||||||||||||||||||
2301 | } else { | - | ||||||||||||||||||
2302 | - | |||||||||||||||||||
2303 | } | - | ||||||||||||||||||
2304 | delete e.event; | - | ||||||||||||||||||
2305 | return true; | - | ||||||||||||||||||
2306 | } | - | ||||||||||||||||||
2307 | QSet<QAbstractState*> QStateMachine::configuration() const | - | ||||||||||||||||||
2308 | { | - | ||||||||||||||||||
2309 | const QStateMachinePrivate * const d = d_func(); | - | ||||||||||||||||||
2310 | return d->configuration; | - | ||||||||||||||||||
2311 | } | - | ||||||||||||||||||
2312 | bool QStateMachine::event(QEvent *e) | - | ||||||||||||||||||
2313 | { | - | ||||||||||||||||||
2314 | QStateMachinePrivate * const d = d_func(); | - | ||||||||||||||||||
2315 | if (e->type() == QEvent::Timer) { | - | ||||||||||||||||||
2316 | QTimerEvent *te = static_cast<QTimerEvent*>(e); | - | ||||||||||||||||||
2317 | int tid = te->timerId(); | - | ||||||||||||||||||
2318 | if (d->state != QStateMachinePrivate::Running) { | - | ||||||||||||||||||
2319 | - | |||||||||||||||||||
2320 | QMutexLocker locker(&d->delayedEventsMutex); | - | ||||||||||||||||||
2321 | ((!(!d->timerIdToDelayedEventId.contains(tid))) ? qt_assert("!d->timerIdToDelayedEventId.contains(tid)",__FILE__,28472854) : qt_noop()); | - | ||||||||||||||||||
2322 | return true; | - | ||||||||||||||||||
2323 | } | - | ||||||||||||||||||
2324 | d->delayedEventsMutex.lock(); | - | ||||||||||||||||||
2325 | int id = d->timerIdToDelayedEventId.take(tid); | - | ||||||||||||||||||
2326 | QStateMachinePrivate::DelayedEvent ee = d->delayedEvents.take(id); | - | ||||||||||||||||||
2327 | if (ee.event != 0) { | - | ||||||||||||||||||
2328 | ((!(ee.timerId == tid)) ? qt_assert("ee.timerId == tid",__FILE__,28542861) : qt_noop()); | - | ||||||||||||||||||
2329 | killTimer(tid); | - | ||||||||||||||||||
2330 | d->delayedEventIdFreeList.release(id); | - | ||||||||||||||||||
2331 | d->delayedEventsMutex.unlock(); | - | ||||||||||||||||||
2332 | d->postExternalEvent(ee.event); | - | ||||||||||||||||||
2333 | d->processEvents(QStateMachinePrivate::DirectProcessing); | - | ||||||||||||||||||
2334 | return true; | - | ||||||||||||||||||
2335 | } else { | - | ||||||||||||||||||
2336 | d->delayedEventsMutex.unlock(); | - | ||||||||||||||||||
2337 | } | - | ||||||||||||||||||
2338 | } | - | ||||||||||||||||||
2339 | return QState::event(e); | - | ||||||||||||||||||
2340 | } | - | ||||||||||||||||||
2341 | - | |||||||||||||||||||
2342 | - | |||||||||||||||||||
2343 | - | |||||||||||||||||||
2344 | - | |||||||||||||||||||
2345 | - | |||||||||||||||||||
2346 | bool QStateMachine::eventFilter(QObject *watched, QEvent *event) | - | ||||||||||||||||||
2347 | { | - | ||||||||||||||||||
2348 | QStateMachinePrivate * const d = d_func(); | - | ||||||||||||||||||
2349 | d->handleFilteredEvent(watched, event); | - | ||||||||||||||||||
2350 | return false; | - | ||||||||||||||||||
2351 | } | - | ||||||||||||||||||
2352 | void QStateMachine::beginSelectTransitions(QEvent *event) | - | ||||||||||||||||||
2353 | { | - | ||||||||||||||||||
2354 | (void)event;; | - | ||||||||||||||||||
2355 | } | - | ||||||||||||||||||
2356 | void QStateMachine::endSelectTransitions(QEvent *event) | - | ||||||||||||||||||
2357 | { | - | ||||||||||||||||||
2358 | (void)event;; | - | ||||||||||||||||||
2359 | } | - | ||||||||||||||||||
2360 | void QStateMachine::beginMicrostep(QEvent *event) | - | ||||||||||||||||||
2361 | { | - | ||||||||||||||||||
2362 | (void)event;; | - | ||||||||||||||||||
2363 | } | - | ||||||||||||||||||
2364 | void QStateMachine::endMicrostep(QEvent *event) | - | ||||||||||||||||||
2365 | { | - | ||||||||||||||||||
2366 | (void)event;; | - | ||||||||||||||||||
2367 | } | - | ||||||||||||||||||
2368 | - | |||||||||||||||||||
2369 | - | |||||||||||||||||||
2370 | - | |||||||||||||||||||
2371 | - | |||||||||||||||||||
2372 | - | |||||||||||||||||||
2373 | void QStateMachine::onEntry(QEvent *event) | - | ||||||||||||||||||
2374 | { | - | ||||||||||||||||||
2375 | start(); | - | ||||||||||||||||||
2376 | QState::onEntry(event); | - | ||||||||||||||||||
2377 | } | - | ||||||||||||||||||
2378 | - | |||||||||||||||||||
2379 | - | |||||||||||||||||||
2380 | - | |||||||||||||||||||
2381 | - | |||||||||||||||||||
2382 | - | |||||||||||||||||||
2383 | - | |||||||||||||||||||
2384 | void QStateMachine::onExit(QEvent *event) | - | ||||||||||||||||||
2385 | { | - | ||||||||||||||||||
2386 | stop(); | - | ||||||||||||||||||
2387 | QState::onExit(event); | - | ||||||||||||||||||
2388 | } | - | ||||||||||||||||||
2389 | - | |||||||||||||||||||
2390 | - | |||||||||||||||||||
2391 | - | |||||||||||||||||||
2392 | - | |||||||||||||||||||
2393 | - | |||||||||||||||||||
2394 | - | |||||||||||||||||||
2395 | bool QStateMachine::isAnimated() const | - | ||||||||||||||||||
2396 | { | - | ||||||||||||||||||
2397 | const QStateMachinePrivate * const d = d_func(); | - | ||||||||||||||||||
2398 | return d->animated; | - | ||||||||||||||||||
2399 | } | - | ||||||||||||||||||
2400 | - | |||||||||||||||||||
2401 | - | |||||||||||||||||||
2402 | - | |||||||||||||||||||
2403 | - | |||||||||||||||||||
2404 | void QStateMachine::setAnimated(bool enabled) | - | ||||||||||||||||||
2405 | { | - | ||||||||||||||||||
2406 | QStateMachinePrivate * const d = d_func(); | - | ||||||||||||||||||
2407 | d->animated = enabled; | - | ||||||||||||||||||
2408 | } | - | ||||||||||||||||||
2409 | - | |||||||||||||||||||
2410 | - | |||||||||||||||||||
2411 | - | |||||||||||||||||||
2412 | - | |||||||||||||||||||
2413 | void QStateMachine::addDefaultAnimation(QAbstractAnimation *animation) | - | ||||||||||||||||||
2414 | { | - | ||||||||||||||||||
2415 | QStateMachinePrivate * const d = d_func(); | - | ||||||||||||||||||
2416 | d->defaultAnimations.append(animation); | - | ||||||||||||||||||
2417 | } | - | ||||||||||||||||||
2418 | - | |||||||||||||||||||
2419 | - | |||||||||||||||||||
2420 | - | |||||||||||||||||||
2421 | - | |||||||||||||||||||
2422 | QList<QAbstractAnimation*> QStateMachine::defaultAnimations() const | - | ||||||||||||||||||
2423 | { | - | ||||||||||||||||||
2424 | const QStateMachinePrivate * const d = d_func(); | - | ||||||||||||||||||
2425 | return d->defaultAnimations; | - | ||||||||||||||||||
2426 | } | - | ||||||||||||||||||
2427 | - | |||||||||||||||||||
2428 | - | |||||||||||||||||||
2429 | - | |||||||||||||||||||
2430 | - | |||||||||||||||||||
2431 | void QStateMachine::removeDefaultAnimation(QAbstractAnimation *animation) | - | ||||||||||||||||||
2432 | { | - | ||||||||||||||||||
2433 | QStateMachinePrivate * const d = d_func(); | - | ||||||||||||||||||
2434 | d->defaultAnimations.removeAll(animation); | - | ||||||||||||||||||
2435 | } | - | ||||||||||||||||||
2436 | - | |||||||||||||||||||
2437 | - | |||||||||||||||||||
2438 | - | |||||||||||||||||||
2439 | - | |||||||||||||||||||
2440 | - | |||||||||||||||||||
2441 | struct qt_meta_stringdata_QSignalEventGenerator_t { | - | ||||||||||||||||||
2442 | QByteArrayData data[3]; | - | ||||||||||||||||||
2443 | char stringdata[32]; | - | ||||||||||||||||||
2444 | }; | - | ||||||||||||||||||
2445 | - | |||||||||||||||||||
2446 | - | |||||||||||||||||||
2447 | - | |||||||||||||||||||
2448 | - | |||||||||||||||||||
2449 | - | |||||||||||||||||||
2450 | static const qt_meta_stringdata_QSignalEventGenerator_t qt_meta_stringdata_QSignalEventGenerator = { | - | ||||||||||||||||||
2451 | { | - | ||||||||||||||||||
2452 | { { { -1 } }, 21, 0, 0, __builtin_offsetof (qt_meta_stringdata_QSignalEventGenerator_t, stringdata) + 0 - 0 * sizeof(QByteArrayData) }, | - | ||||||||||||||||||
2453 | { { { -1 } }, 7, 0, 0, __builtin_offsetof (qt_meta_stringdata_QSignalEventGenerator_t, stringdata) + 22 - 1 * sizeof(QByteArrayData) }, | - | ||||||||||||||||||
2454 | { { { -1 } }, 0, 0, 0, __builtin_offsetof (qt_meta_stringdata_QSignalEventGenerator_t, stringdata) + 30 - 2 * sizeof(QByteArrayData) } | - | ||||||||||||||||||
2455 | }, | - | ||||||||||||||||||
2456 | "QSignalEventGenerator\0execute\0\0" | - | ||||||||||||||||||
2457 | }; | - | ||||||||||||||||||
2458 | - | |||||||||||||||||||
2459 | - | |||||||||||||||||||
2460 | static const uint qt_meta_data_QSignalEventGenerator[] = { | - | ||||||||||||||||||
2461 | - | |||||||||||||||||||
2462 | - | |||||||||||||||||||
2463 | 7, | - | ||||||||||||||||||
2464 | 0, | - | ||||||||||||||||||
2465 | 0, 0, | - | ||||||||||||||||||
2466 | 1, 14, | - | ||||||||||||||||||
2467 | 0, 0, | - | ||||||||||||||||||
2468 | 0, 0, | - | ||||||||||||||||||
2469 | 0, 0, | - | ||||||||||||||||||
2470 | 0, | - | ||||||||||||||||||
2471 | 0, | - | ||||||||||||||||||
2472 | - | |||||||||||||||||||
2473 | - | |||||||||||||||||||
2474 | 1, 0, 19, 2, 0x0a, | - | ||||||||||||||||||
2475 | - | |||||||||||||||||||
2476 | - | |||||||||||||||||||
2477 | QMetaType::Void, | - | ||||||||||||||||||
2478 | - | |||||||||||||||||||
2479 | 0 | - | ||||||||||||||||||
2480 | }; | - | ||||||||||||||||||
2481 | - | |||||||||||||||||||
2482 | void QSignalEventGenerator::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) | - | ||||||||||||||||||
2483 | { | - | ||||||||||||||||||
2484 | if (_c == QMetaObject::InvokeMetaMethod) { | - | ||||||||||||||||||
2485 | ((!(staticMetaObject.cast(_o))) ? qt_assert("staticMetaObject.cast(_o)",__FILE__,30473054) : qt_noop()); | - | ||||||||||||||||||
2486 | QSignalEventGenerator *_t = static_cast<QSignalEventGenerator *>(_o); | - | ||||||||||||||||||
2487 | switch (_id) { | - | ||||||||||||||||||
2488 | case 0: _t->execute(_a); break; | - | ||||||||||||||||||
2489 | default: ; | - | ||||||||||||||||||
2490 | } | - | ||||||||||||||||||
2491 | } | - | ||||||||||||||||||
2492 | (void)_a;; | - | ||||||||||||||||||
2493 | } | - | ||||||||||||||||||
2494 | - | |||||||||||||||||||
2495 | const QMetaObject QSignalEventGenerator::staticMetaObject = { | - | ||||||||||||||||||
2496 | { &QObject::staticMetaObject, qt_meta_stringdata_QSignalEventGenerator.data, | - | ||||||||||||||||||
2497 | qt_meta_data_QSignalEventGenerator, qt_static_metacall, 0, 0 } | - | ||||||||||||||||||
2498 | }; | - | ||||||||||||||||||
2499 | - | |||||||||||||||||||
2500 | const QMetaObject *QSignalEventGenerator::metaObject() const | - | ||||||||||||||||||
2501 | { | - | ||||||||||||||||||
2502 | return &staticMetaObject; | - | ||||||||||||||||||
2503 | } | - | ||||||||||||||||||
2504 | - | |||||||||||||||||||
2505 | void *QSignalEventGenerator::qt_metacast(const char *_clname) | - | ||||||||||||||||||
2506 | { | - | ||||||||||||||||||
2507 | if (!_clname) return 0; | - | ||||||||||||||||||
2508 | if (!strcmp(_clname, qt_meta_stringdata_QSignalEventGenerator.stringdata)) | - | ||||||||||||||||||
2509 | return static_cast<void*>(const_cast< QSignalEventGenerator*>(this)); | - | ||||||||||||||||||
2510 | return QObject::qt_metacast(_clname); | - | ||||||||||||||||||
2511 | } | - | ||||||||||||||||||
2512 | - | |||||||||||||||||||
2513 | int QSignalEventGenerator::qt_metacall(QMetaObject::Call _c, int _id, void **_a) | - | ||||||||||||||||||
2514 | { | - | ||||||||||||||||||
2515 | _id = QObject::qt_metacall(_c, _id, _a); | - | ||||||||||||||||||
2516 | if (_id < 0) | - | ||||||||||||||||||
2517 | return _id; | - | ||||||||||||||||||
2518 | if (_c == QMetaObject::InvokeMetaMethod) { | - | ||||||||||||||||||
2519 | if (_id < 1) | - | ||||||||||||||||||
2520 | qt_static_metacall(this, _c, _id, _a); | - | ||||||||||||||||||
2521 | _id -= 1; | - | ||||||||||||||||||
2522 | } | - | ||||||||||||||||||
2523 | return _id; | - | ||||||||||||||||||
2524 | } | - | ||||||||||||||||||
2525 | - | |||||||||||||||||||
2526 | - | |||||||||||||||||||
2527 | void QSignalEventGenerator::execute(void **_a) | - | ||||||||||||||||||
2528 | { | - | ||||||||||||||||||
2529 | int signalIndex = senderSignalIndex(); | - | ||||||||||||||||||
2530 | ((!(signalIndex != -1)) ? qt_assert("signalIndex != -1",__FILE__,30923099) : qt_noop()); | - | ||||||||||||||||||
2531 | QStateMachine *machine = qobject_cast<QStateMachine*>(parent()); | - | ||||||||||||||||||
2532 | QStateMachinePrivate::get(machine)->handleTransitionSignal(sender(), signalIndex, _a); | - | ||||||||||||||||||
2533 | } | - | ||||||||||||||||||
2534 | - | |||||||||||||||||||
2535 | QSignalEventGenerator::QSignalEventGenerator(QStateMachine *parent) | - | ||||||||||||||||||
2536 | : QObject(parent) | - | ||||||||||||||||||
2537 | { | - | ||||||||||||||||||
2538 | } | - | ||||||||||||||||||
2539 | QStateMachine::SignalEvent::SignalEvent(QObject *sender, int signalIndex, | - | ||||||||||||||||||
2540 | const QList<QVariant> &arguments) | - | ||||||||||||||||||
2541 | : QEvent(QEvent::StateMachineSignal), m_sender(sender), | - | ||||||||||||||||||
2542 | m_signalIndex(signalIndex), m_arguments(arguments) | - | ||||||||||||||||||
2543 | { | - | ||||||||||||||||||
2544 | } | - | ||||||||||||||||||
2545 | - | |||||||||||||||||||
2546 | - | |||||||||||||||||||
2547 | - | |||||||||||||||||||
2548 | - | |||||||||||||||||||
2549 | QStateMachine::SignalEvent::~SignalEvent() | - | ||||||||||||||||||
2550 | { | - | ||||||||||||||||||
2551 | } | - | ||||||||||||||||||
2552 | QStateMachine::WrappedEvent::WrappedEvent(QObject *object, QEvent *event) | - | ||||||||||||||||||
2553 | : QEvent(QEvent::StateMachineWrapped), m_object(object), m_event(event) | - | ||||||||||||||||||
2554 | { | - | ||||||||||||||||||
2555 | } | - | ||||||||||||||||||
2556 | - | |||||||||||||||||||
2557 | - | |||||||||||||||||||
2558 | - | |||||||||||||||||||
2559 | - | |||||||||||||||||||
2560 | QStateMachine::WrappedEvent::~WrappedEvent() | - | ||||||||||||||||||
2561 | { | - | ||||||||||||||||||
2562 | delete m_event; | - | ||||||||||||||||||
2563 | } | - | ||||||||||||||||||
2564 | - | |||||||||||||||||||
2565 | - | |||||||||||||||||||
Switch to Source code | Preprocessed file |