| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtCore module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 2.1 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | #include "qstatemachine.h" | - |
| 43 | | - |
| 44 | #ifndef QT_NO_STATEMACHINE | - |
| 45 | | - |
| 46 | #include "qstate.h" | - |
| 47 | #include "qstate_p.h" | - |
| 48 | #include "qstatemachine_p.h" | - |
| 49 | #include "qabstracttransition.h" | - |
| 50 | #include "qabstracttransition_p.h" | - |
| 51 | #include "qsignaltransition.h" | - |
| 52 | #include "qsignaltransition_p.h" | - |
| 53 | #include "qsignaleventgenerator_p.h" | - |
| 54 | #include "qabstractstate.h" | - |
| 55 | #include "qabstractstate_p.h" | - |
| 56 | #include "qfinalstate.h" | - |
| 57 | #include "qhistorystate.h" | - |
| 58 | #include "qhistorystate_p.h" | - |
| 59 | #include "private/qobject_p.h" | - |
| 60 | #include "private/qthread_p.h" | - |
| 61 | | - |
| 62 | #ifndef QT_NO_STATEMACHINE_EVENTFILTER | - |
| 63 | #include "qeventtransition.h" | - |
| 64 | #include "qeventtransition_p.h" | - |
| 65 | #endif | - |
| 66 | | - |
| 67 | #ifndef QT_NO_ANIMATION | - |
| 68 | #include "qpropertyanimation.h" | - |
| 69 | #include "qanimationgroup.h" | - |
| 70 | #include <private/qvariantanimation_p.h> | - |
| 71 | #endif | - |
| 72 | | - |
| 73 | #include <QtCore/qmetaobject.h> | - |
| 74 | #include <qdebug.h> | - |
| 75 | | - |
| 76 | QT_BEGIN_NAMESPACE | - |
| 77 | | - |
| 78 | /*! | - |
| 79 | \class QStateMachine | - |
| 80 | \inmodule QtCore | - |
| 81 | \reentrant | - |
| 82 | | - |
| 83 | \brief The QStateMachine class provides a hierarchical finite state machine. | - |
| 84 | | - |
| 85 | \since 4.6 | - |
| 86 | \ingroup statemachine | - |
| 87 | | - |
| 88 | QStateMachine is based on the concepts and notation of | - |
| 89 | \l{http://www.wisdom.weizmann.ac.il/~dharel/SCANNED.PAPERS/Statecharts.pdf}{Statecharts}. | - |
| 90 | QStateMachine is part of \l{The State Machine Framework}. | - |
| 91 | | - |
| 92 | A state machine manages a set of states (classes that inherit from | - |
| 93 | QAbstractState) and transitions (descendants of | - |
| 94 | QAbstractTransition) between those states; these states and | - |
| 95 | transitions define a state graph. Once a state graph has been | - |
| 96 | built, the state machine can execute it. QStateMachine's | - |
| 97 | execution algorithm is based on the \l{http://www.w3.org/TR/scxml/}{State Chart XML (SCXML)} | - |
| 98 | algorithm. The framework's \l{The State Machine | - |
| 99 | Framework}{overview} gives several state graphs and the code to | - |
| 100 | build them. | - |
| 101 | | - |
| 102 | Use the addState() function to add a top-level state to the state machine. | - |
| 103 | States are removed with the removeState() function. Removing states while | - |
| 104 | the machine is running is discouraged. | - |
| 105 | | - |
| 106 | Before the machine can be started, the \l{initialState}{initial | - |
| 107 | state} must be set. The initial state is the state that the | - |
| 108 | machine enters when started. You can then start() the state | - |
| 109 | machine. The started() signal is emitted when the initial state is | - |
| 110 | entered. | - |
| 111 | | - |
| 112 | The machine is event driven and keeps its own event loop. Events | - |
| 113 | are posted to the machine through postEvent(). Note that this | - |
| 114 | means that it executes asynchronously, and that it will not | - |
| 115 | progress without a running event loop. You will normally not have | - |
| 116 | to post events to the machine directly as Qt's transitions, e.g., | - |
| 117 | QEventTransition and its subclasses, handle this. But for custom | - |
| 118 | transitions triggered by events, postEvent() is useful. | - |
| 119 | | - |
| 120 | The state machine processes events and takes transitions until a | - |
| 121 | top-level final state is entered; the state machine then emits the | - |
| 122 | finished() signal. You can also stop() the state machine | - |
| 123 | explicitly. The stopped() signal is emitted in this case. | - |
| 124 | | - |
| 125 | The following snippet shows a state machine that will finish when a button | - |
| 126 | is clicked: | - |
| 127 | | - |
| 128 | \snippet code/src_corelib_statemachine_qstatemachine.cpp simple state machine | - |
| 129 | | - |
| 130 | This code example uses QState, which inherits QAbstractState. The | - |
| 131 | QState class provides a state that you can use to set properties | - |
| 132 | and invoke methods on \l{QObject}s when the state is entered or | - |
| 133 | exited. It also contains convenience functions for adding | - |
| 134 | transitions, e.g., \l{QSignalTransition}s as in this example. See | - |
| 135 | the QState class description for further details. | - |
| 136 | | - |
| 137 | If an error is encountered, the machine will look for an | - |
| 138 | \l{errorState}{error state}, and if one is available, it will | - |
| 139 | enter this state. The types of errors possible are described by the | - |
| 140 | \l{QStateMachine::}{Error} enum. After the error state is entered, | - |
| 141 | the type of the error can be retrieved with error(). The execution | - |
| 142 | of the state graph will not stop when the error state is entered. If | - |
| 143 | no error state applies to the erroneous state, the machine will stop | - |
| 144 | executing and an error message will be printed to the console. | - |
| 145 | | - |
| 146 | \sa QAbstractState, QAbstractTransition, QState, {The State Machine Framework} | - |
| 147 | */ | - |
| 148 | | - |
| 149 | /*! | - |
| 150 | \property QStateMachine::errorString | - |
| 151 | | - |
| 152 | \brief the error string of this state machine | - |
| 153 | */ | - |
| 154 | | - |
| 155 | /*! | - |
| 156 | \property QStateMachine::globalRestorePolicy | - |
| 157 | | - |
| 158 | \brief the restore policy for states of this state machine. | - |
| 159 | | - |
| 160 | The default value of this property is | - |
| 161 | QState::DontRestoreProperties. | - |
| 162 | */ | - |
| 163 | | - |
| 164 | #ifndef QT_NO_ANIMATION | - |
| 165 | /*! | - |
| 166 | \property QStateMachine::animated | - |
| 167 | | - |
| 168 | \brief whether animations are enabled | - |
| 169 | | - |
| 170 | The default value of this property is true. | - |
| 171 | | - |
| 172 | \sa QAbstractTransition::addAnimation() | - |
| 173 | */ | - |
| 174 | #endif | - |
| 175 | | - |
| 176 | // #define QSTATEMACHINE_DEBUG | - |
| 177 | // #define QSTATEMACHINE_RESTORE_PROPERTIES_DEBUG | - |
| 178 | | - |
| 179 | template <class T> | - |
| 180 | static uint qHash(const QPointer<T> &p) | - |
| 181 | { return qHash(p.data()); } executed: return qHash(p.data());Execution Count:265 | 265 |
| 182 | | - |
| 183 | QStateMachinePrivate::QStateMachinePrivate() | - |
| 184 | { | - |
| 185 | isMachine = true; executed (the execution status of this line is deduced): isMachine = true; | - |
| 186 | | - |
| 187 | state = NotRunning; executed (the execution status of this line is deduced): state = NotRunning; | - |
| 188 | processing = false; executed (the execution status of this line is deduced): processing = false; | - |
| 189 | processingScheduled = false; executed (the execution status of this line is deduced): processingScheduled = false; | - |
| 190 | stop = false; executed (the execution status of this line is deduced): stop = false; | - |
| 191 | stopProcessingReason = EventQueueEmpty; executed (the execution status of this line is deduced): stopProcessingReason = EventQueueEmpty; | - |
| 192 | error = QStateMachine::NoError; executed (the execution status of this line is deduced): error = QStateMachine::NoError; | - |
| 193 | globalRestorePolicy = QState::DontRestoreProperties; executed (the execution status of this line is deduced): globalRestorePolicy = QState::DontRestoreProperties; | - |
| 194 | signalEventGenerator = 0; executed (the execution status of this line is deduced): signalEventGenerator = 0; | - |
| 195 | #ifndef QT_NO_ANIMATION | - |
| 196 | animated = true; executed (the execution status of this line is deduced): animated = true; | - |
| 197 | #endif | - |
| 198 | } executed: }Execution Count:134 | 134 |
| 199 | | - |
| 200 | QStateMachinePrivate::~QStateMachinePrivate() | - |
| 201 | { | - |
| 202 | qDeleteAll(internalEventQueue); executed (the execution status of this line is deduced): qDeleteAll(internalEventQueue); | - |
| 203 | qDeleteAll(externalEventQueue); executed (the execution status of this line is deduced): qDeleteAll(externalEventQueue); | - |
| 204 | } executed: }Execution Count:134 | 134 |
| 205 | | - |
| 206 | QStateMachinePrivate *QStateMachinePrivate::get(QStateMachine *q) | - |
| 207 | { | - |
| 208 | if (q) evaluated: q| yes Evaluation Count:300328 | yes Evaluation Count:1 |
| 1-300328 |
| 209 | return q->d_func(); executed: return q->d_func();Execution Count:300330 | 300330 |
| 210 | return 0; executed: return 0;Execution Count:1 | 1 |
| 211 | } | - |
| 212 | | - |
| 213 | QState *QStateMachinePrivate::rootState() const | - |
| 214 | { | - |
| 215 | return const_cast<QStateMachine*>(q_func()); executed: return const_cast<QStateMachine*>(q_func());Execution Count:9505 | 9505 |
| 216 | } | - |
| 217 | | - |
| 218 | static QEvent *cloneEvent(QEvent *e) | - |
| 219 | { | - |
| 220 | switch (e->type()) { | - |
| 221 | case QEvent::None: | - |
| 222 | return new QEvent(*e); never executed: return new QEvent(*e); | 0 |
| 223 | case QEvent::Timer: | - |
| 224 | return new QTimerEvent(*static_cast<QTimerEvent*>(e)); executed: return new QTimerEvent(*static_cast<QTimerEvent*>(e));Execution Count:7 | 7 |
| 225 | default: | - |
| 226 | Q_ASSERT_X(false, "cloneEvent()", "not implemented"); never executed (the execution status of this line is deduced): qt_noop(); | - |
| 227 | break; | 0 |
| 228 | } | - |
| 229 | return 0; never executed: return 0; | 0 |
| 230 | } | - |
| 231 | | - |
| 232 | const QStateMachinePrivate::Handler qt_kernel_statemachine_handler = { | - |
| 233 | cloneEvent | - |
| 234 | }; | - |
| 235 | | - |
| 236 | const QStateMachinePrivate::Handler *QStateMachinePrivate::handler = &qt_kernel_statemachine_handler; | - |
| 237 | | - |
| 238 | Q_CORE_EXPORT const QStateMachinePrivate::Handler *qcoreStateMachineHandler() | - |
| 239 | { | - |
| 240 | return &qt_kernel_statemachine_handler; executed: return &qt_kernel_statemachine_handler;Execution Count:7 | 7 |
| 241 | } | - |
| 242 | | - |
| 243 | static int indexOfDescendant(QState *s, QAbstractState *desc) | - |
| 244 | { | - |
| 245 | QList<QAbstractState*> childStates = QStatePrivate::get(s)->childStates(); executed (the execution status of this line is deduced): QList<QAbstractState*> childStates = QStatePrivate::get(s)->childStates(); | - |
| 246 | for (int i = 0; i < childStates.size(); ++i) { partially evaluated: i < childStates.size()| yes Evaluation Count:122 | no Evaluation Count:0 |
| 0-122 |
| 247 | QAbstractState *c = childStates.at(i); executed (the execution status of this line is deduced): QAbstractState *c = childStates.at(i); | - |
| 248 | if ((c == desc) || QStateMachinePrivate::isDescendantOf(desc, c)) { evaluated: (c == desc)| yes Evaluation Count:23 | yes Evaluation Count:99 |
evaluated: QStateMachinePrivate::isDescendantOf(desc, c)| yes Evaluation Count:49 | yes Evaluation Count:50 |
| 23-99 |
| 249 | return i; executed: return i;Execution Count:72 | 72 |
| 250 | } | - |
| 251 | } executed: }Execution Count:50 | 50 |
| 252 | return -1; never executed: return -1; | 0 |
| 253 | } | - |
| 254 | | - |
| 255 | bool QStateMachinePrivate::stateEntryLessThan(QAbstractState *s1, QAbstractState *s2) | - |
| 256 | { | - |
| 257 | if (s1->parent() == s2->parent()) { evaluated: s1->parent() == s2->parent()| yes Evaluation Count:10 | yes Evaluation Count:122 |
| 10-122 |
| 258 | return s1->parent()->children().indexOf(s1) executed: return s1->parent()->children().indexOf(s1) < s2->parent()->children().indexOf(s2);Execution Count:10 | 10 |
| 259 | < s2->parent()->children().indexOf(s2); executed: return s1->parent()->children().indexOf(s1) < s2->parent()->children().indexOf(s2);Execution Count:10 | 10 |
| 260 | } else if (isDescendantOf(s1, s2)) { evaluated: isDescendantOf(s1, s2)| yes Evaluation Count:54 | yes Evaluation Count:68 |
| 54-68 |
| 261 | return false; executed: return false;Execution Count:54 | 54 |
| 262 | } else if (isDescendantOf(s2, s1)) { evaluated: isDescendantOf(s2, s1)| yes Evaluation Count:46 | yes Evaluation Count:22 |
| 22-46 |
| 263 | return true; executed: return true;Execution Count:46 | 46 |
| 264 | } else { | - |
| 265 | Q_ASSERT(s1->machine() != 0); executed (the execution status of this line is deduced): qt_noop(); | - |
| 266 | QStateMachinePrivate *mach = QStateMachinePrivate::get(s1->machine()); executed (the execution status of this line is deduced): QStateMachinePrivate *mach = QStateMachinePrivate::get(s1->machine()); | - |
| 267 | QState *lca = mach->findLCA(QList<QAbstractState*>() << s1 << s2); executed (the execution status of this line is deduced): QState *lca = mach->findLCA(QList<QAbstractState*>() << s1 << s2); | - |
| 268 | Q_ASSERT(lca != 0); executed (the execution status of this line is deduced): qt_noop(); | - |
| 269 | return (indexOfDescendant(lca, s1) < indexOfDescendant(lca, s2)); executed: return (indexOfDescendant(lca, s1) < indexOfDescendant(lca, s2));Execution Count:22 | 22 |
| 270 | } | - |
| 271 | } | - |
| 272 | | - |
| 273 | bool QStateMachinePrivate::stateExitLessThan(QAbstractState *s1, QAbstractState *s2) | - |
| 274 | { | - |
| 275 | if (s1->parent() == s2->parent()) { evaluated: s1->parent() == s2->parent()| yes Evaluation Count:7 | yes Evaluation Count:82 |
| 7-82 |
| 276 | return s2->parent()->children().indexOf(s2) executed: return s2->parent()->children().indexOf(s2) < s1->parent()->children().indexOf(s1);Execution Count:7 | 7 |
| 277 | < s1->parent()->children().indexOf(s1); executed: return s2->parent()->children().indexOf(s2) < s1->parent()->children().indexOf(s1);Execution Count:7 | 7 |
| 278 | } else if (isDescendantOf(s1, s2)) { evaluated: isDescendantOf(s1, s2)| yes Evaluation Count:31 | yes Evaluation Count:51 |
| 31-51 |
| 279 | return true; executed: return true;Execution Count:31 | 31 |
| 280 | } else if (isDescendantOf(s2, s1)) { evaluated: isDescendantOf(s2, s1)| yes Evaluation Count:37 | yes Evaluation Count:14 |
| 14-37 |
| 281 | return false; executed: return false;Execution Count:37 | 37 |
| 282 | } else { | - |
| 283 | Q_ASSERT(s1->machine() != 0); executed (the execution status of this line is deduced): qt_noop(); | - |
| 284 | QStateMachinePrivate *mach = QStateMachinePrivate::get(s1->machine()); executed (the execution status of this line is deduced): QStateMachinePrivate *mach = QStateMachinePrivate::get(s1->machine()); | - |
| 285 | QState *lca = mach->findLCA(QList<QAbstractState*>() << s1 << s2); executed (the execution status of this line is deduced): QState *lca = mach->findLCA(QList<QAbstractState*>() << s1 << s2); | - |
| 286 | Q_ASSERT(lca != 0); executed (the execution status of this line is deduced): qt_noop(); | - |
| 287 | return (indexOfDescendant(lca, s2) < indexOfDescendant(lca, s1)); executed: return (indexOfDescendant(lca, s2) < indexOfDescendant(lca, s1));Execution Count:14 | 14 |
| 288 | } | - |
| 289 | } | - |
| 290 | | - |
| 291 | QState *QStateMachinePrivate::findLCA(const QList<QAbstractState*> &states) const | - |
| 292 | { | - |
| 293 | if (states.isEmpty()) partially evaluated: states.isEmpty()| no Evaluation Count:0 | yes Evaluation Count:2643 |
| 0-2643 |
| 294 | return 0; never executed: return 0; | 0 |
| 295 | QList<QState*> ancestors = properAncestors(states.at(0), rootState()->parentState()); executed (the execution status of this line is deduced): QList<QState*> ancestors = properAncestors(states.at(0), rootState()->parentState()); | - |
| 296 | for (int i = 0; i < ancestors.size(); ++i) { evaluated: i < ancestors.size()| yes Evaluation Count:2696 | yes Evaluation Count:6 |
| 6-2696 |
| 297 | QState *anc = ancestors.at(i); executed (the execution status of this line is deduced): QState *anc = ancestors.at(i); | - |
| 298 | bool ok = true; executed (the execution status of this line is deduced): bool ok = true; | - |
| 299 | for (int j = states.size() - 1; (j > 0) && ok; --j) { evaluated: (j > 0)| yes Evaluation Count:2553 | yes Evaluation Count:2696 |
partially evaluated: ok| yes Evaluation Count:2553 | no Evaluation Count:0 |
| 0-2696 |
| 300 | const QAbstractState *s = states.at(j); executed (the execution status of this line is deduced): const QAbstractState *s = states.at(j); | - |
| 301 | if (!isDescendantOf(s, anc)) evaluated: !isDescendantOf(s, anc)| yes Evaluation Count:59 | yes Evaluation Count:2494 |
| 59-2494 |
| 302 | ok = false; executed: ok = false;Execution Count:59 | 59 |
| 303 | } executed: }Execution Count:2553 | 2553 |
| 304 | if (ok) evaluated: ok| yes Evaluation Count:2637 | yes Evaluation Count:59 |
| 59-2637 |
| 305 | return anc; executed: return anc;Execution Count:2637 | 2637 |
| 306 | } executed: }Execution Count:59 | 59 |
| 307 | return 0; executed: return 0;Execution Count:6 | 6 |
| 308 | } | - |
| 309 | | - |
| 310 | bool QStateMachinePrivate::isPreempted(const QAbstractState *s, const QSet<QAbstractTransition*> &transitions) const | - |
| 311 | { | - |
| 312 | QSet<QAbstractTransition*>::const_iterator it; executed (the execution status of this line is deduced): QSet<QAbstractTransition*>::const_iterator it; | - |
| 313 | for (it = transitions.constBegin(); it != transitions.constEnd(); ++it) { evaluated: it != transitions.constEnd()| yes Evaluation Count:9 | yes Evaluation Count:4745 |
| 9-4745 |
| 314 | QAbstractTransition *t = *it; executed (the execution status of this line is deduced): QAbstractTransition *t = *it; | - |
| 315 | QList<QAbstractState*> lst = t->targetStates(); executed (the execution status of this line is deduced): QList<QAbstractState*> lst = t->targetStates(); | - |
| 316 | if (!lst.isEmpty()) { partially evaluated: !lst.isEmpty()| yes Evaluation Count:9 | no Evaluation Count:0 |
| 0-9 |
| 317 | lst.prepend(t->sourceState()); executed (the execution status of this line is deduced): lst.prepend(t->sourceState()); | - |
| 318 | QAbstractState *lca = findLCA(lst); executed (the execution status of this line is deduced): QAbstractState *lca = findLCA(lst); | - |
| 319 | if (isDescendantOf(s, lca)) { evaluated: isDescendantOf(s, lca)| yes Evaluation Count:4 | yes Evaluation Count:5 |
| 4-5 |
| 320 | #ifdef QSTATEMACHINE_DEBUG | - |
| 321 | qDebug() << q_func() << ':' << transitions << "preempts selection of a transition from" | - |
| 322 | << s << "because" << s << "is a descendant of" << lca; | - |
| 323 | #endif | - |
| 324 | return true; executed: return true;Execution Count:4 | 4 |
| 325 | } | - |
| 326 | } executed: }Execution Count:5 | 5 |
| 327 | } executed: }Execution Count:5 | 5 |
| 328 | return false; executed: return false;Execution Count:4745 | 4745 |
| 329 | } | - |
| 330 | | - |
| 331 | QSet<QAbstractTransition*> QStateMachinePrivate::selectTransitions(QEvent *event) const | - |
| 332 | { | - |
| 333 | Q_Q(const QStateMachine); executed (the execution status of this line is deduced): const QStateMachine * const q = q_func(); | - |
| 334 | QSet<QAbstractTransition*> enabledTransitions; executed (the execution status of this line is deduced): QSet<QAbstractTransition*> enabledTransitions; | - |
| 335 | QSet<QAbstractState*>::const_iterator it; executed (the execution status of this line is deduced): QSet<QAbstractState*>::const_iterator it; | - |
| 336 | const_cast<QStateMachine*>(q)->beginSelectTransitions(event); executed (the execution status of this line is deduced): const_cast<QStateMachine*>(q)->beginSelectTransitions(event); | - |
| 337 | for (it = configuration.constBegin(); it != configuration.constEnd(); ++it) { evaluated: it != configuration.constEnd()| yes Evaluation Count:5038 | yes Evaluation Count:4709 |
| 4709-5038 |
| 338 | QAbstractState *state = *it; executed (the execution status of this line is deduced): QAbstractState *state = *it; | - |
| 339 | if (!isAtomic(state)) evaluated: !isAtomic(state)| yes Evaluation Count:289 | yes Evaluation Count:4749 |
| 289-4749 |
| 340 | continue; executed: continue;Execution Count:289 | 289 |
| 341 | if (isPreempted(state, enabledTransitions)) evaluated: isPreempted(state, enabledTransitions)| yes Evaluation Count:4 | yes Evaluation Count:4745 |
| 4-4745 |
| 342 | continue; executed: continue;Execution Count:4 | 4 |
| 343 | QList<QState*> lst = properAncestors(state, rootState()->parentState()); executed (the execution status of this line is deduced): QList<QState*> lst = properAncestors(state, rootState()->parentState()); | - |
| 344 | if (QState *grp = toStandardState(state)) evaluated: QState *grp = toStandardState(state)| yes Evaluation Count:4727 | yes Evaluation Count:18 |
| 18-4727 |
| 345 | lst.prepend(grp); executed: lst.prepend(grp);Execution Count:4727 | 4727 |
| 346 | bool found = false; executed (the execution status of this line is deduced): bool found = false; | - |
| 347 | for (int j = 0; (j < lst.size()) && !found; ++j) { evaluated: (j < lst.size())| yes Evaluation Count:9738 | yes Evaluation Count:3520 |
evaluated: !found| yes Evaluation Count:8513 | yes Evaluation Count:1225 |
| 1225-9738 |
| 348 | QState *s = lst.at(j); executed (the execution status of this line is deduced): QState *s = lst.at(j); | - |
| 349 | QList<QAbstractTransition*> transitions = QStatePrivate::get(s)->transitions(); executed (the execution status of this line is deduced): QList<QAbstractTransition*> transitions = QStatePrivate::get(s)->transitions(); | - |
| 350 | for (int k = 0; k < transitions.size(); ++k) { evaluated: k < transitions.size()| yes Evaluation Count:7881 | yes Evaluation Count:7288 |
| 7288-7881 |
| 351 | QAbstractTransition *t = transitions.at(k); executed (the execution status of this line is deduced): QAbstractTransition *t = transitions.at(k); | - |
| 352 | if (QAbstractTransitionPrivate::get(t)->callEventTest(event)) { evaluated: QAbstractTransitionPrivate::get(t)->callEventTest(event)| yes Evaluation Count:1225 | yes Evaluation Count:6656 |
| 1225-6656 |
| 353 | #ifdef QSTATEMACHINE_DEBUG | - |
| 354 | qDebug() << q << ": selecting transition" << t; | - |
| 355 | #endif | - |
| 356 | enabledTransitions.insert(t); executed (the execution status of this line is deduced): enabledTransitions.insert(t); | - |
| 357 | found = true; executed (the execution status of this line is deduced): found = true; | - |
| 358 | break; executed: break;Execution Count:1225 | 1225 |
| 359 | } | - |
| 360 | } executed: }Execution Count:6656 | 6656 |
| 361 | } executed: }Execution Count:8513 | 8513 |
| 362 | } executed: }Execution Count:4745 | 4745 |
| 363 | const_cast<QStateMachine*>(q)->endSelectTransitions(event); executed (the execution status of this line is deduced): const_cast<QStateMachine*>(q)->endSelectTransitions(event); | - |
| 364 | return enabledTransitions; executed: return enabledTransitions;Execution Count:4709 | 4709 |
| 365 | } | - |
| 366 | | - |
| 367 | void QStateMachinePrivate::microstep(QEvent *event, const QList<QAbstractTransition*> &enabledTransitions) | - |
| 368 | { | - |
| 369 | #ifdef QSTATEMACHINE_DEBUG | - |
| 370 | qDebug() << q_func() << ": begin microstep( enabledTransitions:" << enabledTransitions << ')'; | - |
| 371 | qDebug() << q_func() << ": configuration before exiting states:" << configuration; | - |
| 372 | #endif | - |
| 373 | QList<QAbstractState*> exitedStates = computeStatesToExit(enabledTransitions); executed (the execution status of this line is deduced): QList<QAbstractState*> exitedStates = computeStatesToExit(enabledTransitions); | - |
| 374 | QHash<RestorableId, QVariant> pendingRestorables = computePendingRestorables(exitedStates); executed (the execution status of this line is deduced): QHash<RestorableId, QVariant> pendingRestorables = computePendingRestorables(exitedStates); | - |
| 375 | | - |
| 376 | QSet<QAbstractState*> statesForDefaultEntry; executed (the execution status of this line is deduced): QSet<QAbstractState*> statesForDefaultEntry; | - |
| 377 | QList<QAbstractState*> enteredStates = computeStatesToEnter(enabledTransitions, statesForDefaultEntry); executed (the execution status of this line is deduced): QList<QAbstractState*> enteredStates = computeStatesToEnter(enabledTransitions, statesForDefaultEntry); | - |
| 378 | | - |
| 379 | QHash<QAbstractState*, QList<QPropertyAssignment> > assignmentsForEnteredStates = executed (the execution status of this line is deduced): QHash<QAbstractState*, QList<QPropertyAssignment> > assignmentsForEnteredStates = | - |
| 380 | computePropertyAssignments(enteredStates, pendingRestorables); executed (the execution status of this line is deduced): computePropertyAssignments(enteredStates, pendingRestorables); | - |
| 381 | if (!pendingRestorables.isEmpty()) { evaluated: !pendingRestorables.isEmpty()| yes Evaluation Count:23 | yes Evaluation Count:1201 |
| 23-1201 |
| 382 | // Add "implicit" assignments for restored properties to the first | - |
| 383 | // (outermost) entered state | - |
| 384 | Q_ASSERT(!enteredStates.isEmpty()); executed (the execution status of this line is deduced): qt_noop(); | - |
| 385 | QAbstractState *s = enteredStates.first(); executed (the execution status of this line is deduced): QAbstractState *s = enteredStates.first(); | - |
| 386 | assignmentsForEnteredStates[s] << restorablesToPropertyList(pendingRestorables); executed (the execution status of this line is deduced): assignmentsForEnteredStates[s] << restorablesToPropertyList(pendingRestorables); | - |
| 387 | } executed: }Execution Count:23 | 23 |
| 388 | | - |
| 389 | exitStates(event, exitedStates, assignmentsForEnteredStates); executed (the execution status of this line is deduced): exitStates(event, exitedStates, assignmentsForEnteredStates); | - |
| 390 | #ifdef QSTATEMACHINE_DEBUG | - |
| 391 | qDebug() << q_func() << ": configuration after exiting states:" << configuration; | - |
| 392 | #endif | - |
| 393 | | - |
| 394 | executeTransitionContent(event, enabledTransitions); executed (the execution status of this line is deduced): executeTransitionContent(event, enabledTransitions); | - |
| 395 | | - |
| 396 | #ifndef QT_NO_ANIMATION | - |
| 397 | QList<QAbstractAnimation *> selectedAnimations = selectAnimations(enabledTransitions); executed (the execution status of this line is deduced): QList<QAbstractAnimation *> selectedAnimations = selectAnimations(enabledTransitions); | - |
| 398 | #endif | - |
| 399 | | - |
| 400 | enterStates(event, exitedStates, enteredStates, statesForDefaultEntry, assignmentsForEnteredStates executed (the execution status of this line is deduced): enterStates(event, exitedStates, enteredStates, statesForDefaultEntry, assignmentsForEnteredStates | - |
| 401 | #ifndef QT_NO_ANIMATION executed (the execution status of this line is deduced): | - |
| 402 | , selectedAnimations executed (the execution status of this line is deduced): , selectedAnimations | - |
| 403 | #endif executed (the execution status of this line is deduced): | - |
| 404 | ); executed (the execution status of this line is deduced): ); | - |
| 405 | #ifdef QSTATEMACHINE_DEBUG | - |
| 406 | qDebug() << q_func() << ": configuration after entering states:" << configuration; | - |
| 407 | qDebug() << q_func() << ": end microstep"; | - |
| 408 | #endif | - |
| 409 | } executed: }Execution Count:1224 | 1224 |
| 410 | | - |
| 411 | QList<QAbstractState*> QStateMachinePrivate::computeStatesToExit(const QList<QAbstractTransition*> &enabledTransitions) | - |
| 412 | { | - |
| 413 | QSet<QAbstractState*> statesToExit; executed (the execution status of this line is deduced): QSet<QAbstractState*> statesToExit; | - |
| 414 | // QSet<QAbstractState*> statesToSnapshot; | - |
| 415 | for (int i = 0; i < enabledTransitions.size(); ++i) { evaluated: i < enabledTransitions.size()| yes Evaluation Count:1225 | yes Evaluation Count:1224 |
| 1224-1225 |
| 416 | QAbstractTransition *t = enabledTransitions.at(i); executed (the execution status of this line is deduced): QAbstractTransition *t = enabledTransitions.at(i); | - |
| 417 | QList<QAbstractState*> lst = t->targetStates(); executed (the execution status of this line is deduced): QList<QAbstractState*> lst = t->targetStates(); | - |
| 418 | if (lst.isEmpty()) evaluated: lst.isEmpty()| yes Evaluation Count:4 | yes Evaluation Count:1221 |
| 4-1221 |
| 419 | continue; executed: continue;Execution Count:4 | 4 |
| 420 | lst.prepend(t->sourceState()); executed (the execution status of this line is deduced): lst.prepend(t->sourceState()); | - |
| 421 | QAbstractState *lca = findLCA(lst); executed (the execution status of this line is deduced): QAbstractState *lca = findLCA(lst); | - |
| 422 | if (lca == 0) { evaluated: lca == 0| yes Evaluation Count:3 | yes Evaluation Count:1218 |
| 3-1218 |
| 423 | setError(QStateMachine::NoCommonAncestorForTransitionError, t->sourceState()); executed (the execution status of this line is deduced): setError(QStateMachine::NoCommonAncestorForTransitionError, t->sourceState()); | - |
| 424 | lst = pendingErrorStates.toList(); executed (the execution status of this line is deduced): lst = pendingErrorStates.toList(); | - |
| 425 | lst.prepend(t->sourceState()); executed (the execution status of this line is deduced): lst.prepend(t->sourceState()); | - |
| 426 | | - |
| 427 | lca = findLCA(lst); executed (the execution status of this line is deduced): lca = findLCA(lst); | - |
| 428 | Q_ASSERT(lca != 0); executed (the execution status of this line is deduced): qt_noop(); | - |
| 429 | } executed: }Execution Count:3 | 3 |
| 430 | | - |
| 431 | { | - |
| 432 | QSet<QAbstractState*>::const_iterator it; executed (the execution status of this line is deduced): QSet<QAbstractState*>::const_iterator it; | - |
| 433 | for (it = configuration.constBegin(); it != configuration.constEnd(); ++it) { evaluated: it != configuration.constEnd()| yes Evaluation Count:1335 | yes Evaluation Count:1221 |
| 1221-1335 |
| 434 | QAbstractState *s = *it; executed (the execution status of this line is deduced): QAbstractState *s = *it; | - |
| 435 | if (isDescendantOf(s, lca)) evaluated: isDescendantOf(s, lca)| yes Evaluation Count:1271 | yes Evaluation Count:64 |
| 64-1271 |
| 436 | statesToExit.insert(s); executed: statesToExit.insert(s);Execution Count:1271 | 1271 |
| 437 | } executed: }Execution Count:1335 | 1335 |
| 438 | } | - |
| 439 | } executed: }Execution Count:1221 | 1221 |
| 440 | QList<QAbstractState*> statesToExit_sorted = statesToExit.toList(); executed (the execution status of this line is deduced): QList<QAbstractState*> statesToExit_sorted = statesToExit.toList(); | - |
| 441 | qSort(statesToExit_sorted.begin(), statesToExit_sorted.end(), stateExitLessThan); executed (the execution status of this line is deduced): qSort(statesToExit_sorted.begin(), statesToExit_sorted.end(), stateExitLessThan); | - |
| 442 | return statesToExit_sorted; executed: return statesToExit_sorted;Execution Count:1224 | 1224 |
| 443 | } | - |
| 444 | | - |
| 445 | void QStateMachinePrivate::exitStates(QEvent *event, const QList<QAbstractState*> &statesToExit_sorted, | - |
| 446 | const QHash<QAbstractState*, QList<QPropertyAssignment> > &assignmentsForEnteredStates) | - |
| 447 | { | - |
| 448 | for (int i = 0; i < statesToExit_sorted.size(); ++i) { evaluated: i < statesToExit_sorted.size()| yes Evaluation Count:1271 | yes Evaluation Count:1224 |
| 1224-1271 |
| 449 | QAbstractState *s = statesToExit_sorted.at(i); executed (the execution status of this line is deduced): QAbstractState *s = statesToExit_sorted.at(i); | - |
| 450 | if (QState *grp = toStandardState(s)) { evaluated: QState *grp = toStandardState(s)| yes Evaluation Count:1265 | yes Evaluation Count:6 |
| 6-1265 |
| 451 | QList<QHistoryState*> hlst = QStatePrivate::get(grp)->historyStates(); executed (the execution status of this line is deduced): QList<QHistoryState*> hlst = QStatePrivate::get(grp)->historyStates(); | - |
| 452 | for (int j = 0; j < hlst.size(); ++j) { evaluated: j < hlst.size()| yes Evaluation Count:8 | yes Evaluation Count:1265 |
| 8-1265 |
| 453 | QHistoryState *h = hlst.at(j); executed (the execution status of this line is deduced): QHistoryState *h = hlst.at(j); | - |
| 454 | QHistoryStatePrivate::get(h)->configuration.clear(); executed (the execution status of this line is deduced): QHistoryStatePrivate::get(h)->configuration.clear(); | - |
| 455 | QSet<QAbstractState*>::const_iterator it; executed (the execution status of this line is deduced): QSet<QAbstractState*>::const_iterator it; | - |
| 456 | for (it = configuration.constBegin(); it != configuration.constEnd(); ++it) { evaluated: it != configuration.constEnd()| yes Evaluation Count:16 | yes Evaluation Count:8 |
| 8-16 |
| 457 | QAbstractState *s0 = *it; executed (the execution status of this line is deduced): QAbstractState *s0 = *it; | - |
| 458 | if (QHistoryStatePrivate::get(h)->historyType == QHistoryState::DeepHistory) { partially evaluated: QHistoryStatePrivate::get(h)->historyType == QHistoryState::DeepHistory| no Evaluation Count:0 | yes Evaluation Count:16 |
| 0-16 |
| 459 | if (isAtomic(s0) && isDescendantOf(s0, s)) never evaluated: isAtomic(s0) never evaluated: isDescendantOf(s0, s) | 0 |
| 460 | QHistoryStatePrivate::get(h)->configuration.append(s0); never executed: QHistoryStatePrivate::get(h)->configuration.append(s0); | 0 |
| 461 | } else if (s0->parentState() == s) { never executed: } evaluated: s0->parentState() == s| yes Evaluation Count:8 | yes Evaluation Count:8 |
| 0-8 |
| 462 | QHistoryStatePrivate::get(h)->configuration.append(s0); executed (the execution status of this line is deduced): QHistoryStatePrivate::get(h)->configuration.append(s0); | - |
| 463 | } executed: }Execution Count:8 | 8 |
| 464 | } | - |
| 465 | #ifdef QSTATEMACHINE_DEBUG | - |
| 466 | qDebug() << q_func() << ": recorded" << ((QHistoryStatePrivate::get(h)->historyType == QHistoryState::DeepHistory) ? "deep" : "shallow") | - |
| 467 | << "history for" << s << "in" << h << ':' << QHistoryStatePrivate::get(h)->configuration; | - |
| 468 | #endif | - |
| 469 | } executed: }Execution Count:8 | 8 |
| 470 | } executed: }Execution Count:1265 | 1265 |
| 471 | } executed: }Execution Count:1271 | 1271 |
| 472 | for (int i = 0; i < statesToExit_sorted.size(); ++i) { evaluated: i < statesToExit_sorted.size()| yes Evaluation Count:1271 | yes Evaluation Count:1224 |
| 1224-1271 |
| 473 | QAbstractState *s = statesToExit_sorted.at(i); executed (the execution status of this line is deduced): QAbstractState *s = statesToExit_sorted.at(i); | - |
| 474 | #ifdef QSTATEMACHINE_DEBUG | - |
| 475 | qDebug() << q_func() << ": exiting" << s; | - |
| 476 | #endif | - |
| 477 | QAbstractStatePrivate::get(s)->callOnExit(event); executed (the execution status of this line is deduced): QAbstractStatePrivate::get(s)->callOnExit(event); | - |
| 478 | | - |
| 479 | #ifndef QT_NO_ANIMATION | - |
| 480 | terminateActiveAnimations(s, assignmentsForEnteredStates); executed (the execution status of this line is deduced): terminateActiveAnimations(s, assignmentsForEnteredStates); | - |
| 481 | #else | - |
| 482 | Q_UNUSED(assignmentsForEnteredStates); | - |
| 483 | #endif | - |
| 484 | | - |
| 485 | configuration.remove(s); executed (the execution status of this line is deduced): configuration.remove(s); | - |
| 486 | QAbstractStatePrivate::get(s)->emitExited(); executed (the execution status of this line is deduced): QAbstractStatePrivate::get(s)->emitExited(); | - |
| 487 | } executed: }Execution Count:1271 | 1271 |
| 488 | } executed: }Execution Count:1224 | 1224 |
| 489 | | - |
| 490 | void QStateMachinePrivate::executeTransitionContent(QEvent *event, const QList<QAbstractTransition*> &enabledTransitions) | - |
| 491 | { | - |
| 492 | for (int i = 0; i < enabledTransitions.size(); ++i) { evaluated: i < enabledTransitions.size()| yes Evaluation Count:1368 | yes Evaluation Count:1367 |
| 1367-1368 |
| 493 | QAbstractTransition *t = enabledTransitions.at(i); executed (the execution status of this line is deduced): QAbstractTransition *t = enabledTransitions.at(i); | - |
| 494 | #ifdef QSTATEMACHINE_DEBUG | - |
| 495 | qDebug() << q_func() << ": triggering" << t; | - |
| 496 | #endif | - |
| 497 | QAbstractTransitionPrivate::get(t)->callOnTransition(event); executed (the execution status of this line is deduced): QAbstractTransitionPrivate::get(t)->callOnTransition(event); | - |
| 498 | QAbstractTransitionPrivate::get(t)->emitTriggered(); executed (the execution status of this line is deduced): QAbstractTransitionPrivate::get(t)->emitTriggered(); | - |
| 499 | } executed: }Execution Count:1368 | 1368 |
| 500 | } executed: }Execution Count:1367 | 1367 |
| 501 | | - |
| 502 | QList<QAbstractState*> QStateMachinePrivate::computeStatesToEnter(const QList<QAbstractTransition *> &enabledTransitions, | - |
| 503 | QSet<QAbstractState *> &statesForDefaultEntry) | - |
| 504 | { | - |
| 505 | QSet<QAbstractState*> statesToEnter; executed (the execution status of this line is deduced): QSet<QAbstractState*> statesToEnter; | - |
| 506 | if (pendingErrorStates.isEmpty()) { partially evaluated: pendingErrorStates.isEmpty()| yes Evaluation Count:1367 | no Evaluation Count:0 |
| 0-1367 |
| 507 | for (int i = 0; i < enabledTransitions.size(); ++i) { evaluated: i < enabledTransitions.size()| yes Evaluation Count:1368 | yes Evaluation Count:1367 |
| 1367-1368 |
| 508 | QAbstractTransition *t = enabledTransitions.at(i); executed (the execution status of this line is deduced): QAbstractTransition *t = enabledTransitions.at(i); | - |
| 509 | QList<QAbstractState*> lst = t->targetStates(); executed (the execution status of this line is deduced): QList<QAbstractState*> lst = t->targetStates(); | - |
| 510 | if (lst.isEmpty()) evaluated: lst.isEmpty()| yes Evaluation Count:4 | yes Evaluation Count:1364 |
| 4-1364 |
| 511 | continue; executed: continue;Execution Count:4 | 4 |
| 512 | QAbstractState *src = t->sourceState(); executed (the execution status of this line is deduced): QAbstractState *src = t->sourceState(); | - |
| 513 | if (src) evaluated: src| yes Evaluation Count:1221 | yes Evaluation Count:143 |
| 143-1221 |
| 514 | lst.prepend(src); executed: lst.prepend(src);Execution Count:1221 | 1221 |
| 515 | QState *lca = findLCA(lst); executed (the execution status of this line is deduced): QState *lca = findLCA(lst); | - |
| 516 | for (int j = src ? 1 : 0; j < lst.size(); ++j) { evaluated: j < lst.size()| yes Evaluation Count:1366 | yes Evaluation Count:1364 |
| 1364-1366 |
| 517 | QAbstractState *s = lst.at(j); executed (the execution status of this line is deduced): QAbstractState *s = lst.at(j); | - |
| 518 | addStatesToEnter(s, lca, statesToEnter, statesForDefaultEntry); executed (the execution status of this line is deduced): addStatesToEnter(s, lca, statesToEnter, statesForDefaultEntry); | - |
| 519 | } executed: }Execution Count:1366 | 1366 |
| 520 | for (int j = src ? 1 : 0; j < lst.size(); ++j) { evaluated: j < lst.size()| yes Evaluation Count:1366 | yes Evaluation Count:1364 |
| 1364-1366 |
| 521 | QAbstractState *s = lst.at(j); executed (the execution status of this line is deduced): QAbstractState *s = lst.at(j); | - |
| 522 | addAncestorStatesToEnter(s, lca, statesToEnter, statesForDefaultEntry); executed (the execution status of this line is deduced): addAncestorStatesToEnter(s, lca, statesToEnter, statesForDefaultEntry); | - |
| 523 | } executed: }Execution Count:1366 | 1366 |
| 524 | if (isParallel(lca)) { evaluated: isParallel(lca)| yes Evaluation Count:2 | yes Evaluation Count:1362 |
| 2-1362 |
| 525 | QList<QAbstractState*> lcac = QStatePrivate::get(lca)->childStates(); executed (the execution status of this line is deduced): QList<QAbstractState*> lcac = QStatePrivate::get(lca)->childStates(); | - |
| 526 | foreach (QAbstractState* child,lcac) { executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(lcac)> _container_(lcac); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QAbstractState* child = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
| 527 | if (!statesToEnter.contains(child)) evaluated: !statesToEnter.contains(child)| yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-3 |
| 528 | addStatesToEnter(child,lca,statesToEnter,statesForDefaultEntry); executed: addStatesToEnter(child,lca,statesToEnter,statesForDefaultEntry);Execution Count:1 | 1 |
| 529 | } executed: }Execution Count:4 | 4 |
| 530 | } executed: }Execution Count:2 | 2 |
| 531 | } executed: }Execution Count:1364 | 1364 |
| 532 | } executed: }Execution Count:1367 | 1367 |
| 533 | | - |
| 534 | // Did an error occur while selecting transitions? Then we enter the error state. | - |
| 535 | if (!pendingErrorStates.isEmpty()) { evaluated: !pendingErrorStates.isEmpty()| yes Evaluation Count:9 | yes Evaluation Count:1358 |
| 9-1358 |
| 536 | statesToEnter.clear(); executed (the execution status of this line is deduced): statesToEnter.clear(); | - |
| 537 | statesToEnter = pendingErrorStates; executed (the execution status of this line is deduced): statesToEnter = pendingErrorStates; | - |
| 538 | statesForDefaultEntry = pendingErrorStatesForDefaultEntry; executed (the execution status of this line is deduced): statesForDefaultEntry = pendingErrorStatesForDefaultEntry; | - |
| 539 | pendingErrorStates.clear(); executed (the execution status of this line is deduced): pendingErrorStates.clear(); | - |
| 540 | pendingErrorStatesForDefaultEntry.clear(); executed (the execution status of this line is deduced): pendingErrorStatesForDefaultEntry.clear(); | - |
| 541 | } executed: }Execution Count:9 | 9 |
| 542 | | - |
| 543 | QList<QAbstractState*> statesToEnter_sorted = statesToEnter.toList(); executed (the execution status of this line is deduced): QList<QAbstractState*> statesToEnter_sorted = statesToEnter.toList(); | - |
| 544 | qSort(statesToEnter_sorted.begin(), statesToEnter_sorted.end(), stateEntryLessThan); executed (the execution status of this line is deduced): qSort(statesToEnter_sorted.begin(), statesToEnter_sorted.end(), stateEntryLessThan); | - |
| 545 | return statesToEnter_sorted; executed: return statesToEnter_sorted;Execution Count:1367 | 1367 |
| 546 | } | - |
| 547 | | - |
| 548 | void QStateMachinePrivate::enterStates(QEvent *event, const QList<QAbstractState*> &exitedStates_sorted, | - |
| 549 | const QList<QAbstractState*> &statesToEnter_sorted, | - |
| 550 | const QSet<QAbstractState*> &statesForDefaultEntry, | - |
| 551 | QHash<QAbstractState*, QList<QPropertyAssignment> > &propertyAssignmentsForState | - |
| 552 | #ifndef QT_NO_ANIMATION | - |
| 553 | , const QList<QAbstractAnimation *> &selectedAnimations | - |
| 554 | #endif | - |
| 555 | ) | - |
| 556 | { | - |
| 557 | #ifdef QSTATEMACHINE_DEBUG | - |
| 558 | Q_Q(QStateMachine); | - |
| 559 | #endif | - |
| 560 | for (int i = 0; i < statesToEnter_sorted.size(); ++i) { evaluated: i < statesToEnter_sorted.size()| yes Evaluation Count:1442 | yes Evaluation Count:1367 |
| 1367-1442 |
| 561 | QAbstractState *s = statesToEnter_sorted.at(i); executed (the execution status of this line is deduced): QAbstractState *s = statesToEnter_sorted.at(i); | - |
| 562 | #ifdef QSTATEMACHINE_DEBUG | - |
| 563 | qDebug() << q << ": entering" << s; | - |
| 564 | #endif | - |
| 565 | configuration.insert(s); executed (the execution status of this line is deduced): configuration.insert(s); | - |
| 566 | registerTransitions(s); executed (the execution status of this line is deduced): registerTransitions(s); | - |
| 567 | | - |
| 568 | #ifndef QT_NO_ANIMATION | - |
| 569 | initializeAnimations(s, selectedAnimations, exitedStates_sorted, propertyAssignmentsForState); executed (the execution status of this line is deduced): initializeAnimations(s, selectedAnimations, exitedStates_sorted, propertyAssignmentsForState); | - |
| 570 | #endif | - |
| 571 | | - |
| 572 | // Immediately set the properties that are not animated. | - |
| 573 | { | - |
| 574 | QList<QPropertyAssignment> assignments = propertyAssignmentsForState.value(s); executed (the execution status of this line is deduced): QList<QPropertyAssignment> assignments = propertyAssignmentsForState.value(s); | - |
| 575 | for (int i = 0; i < assignments.size(); ++i) { evaluated: i < assignments.size()| yes Evaluation Count:97 | yes Evaluation Count:1442 |
| 97-1442 |
| 576 | const QPropertyAssignment &assn = assignments.at(i); executed (the execution status of this line is deduced): const QPropertyAssignment &assn = assignments.at(i); | - |
| 577 | if (globalRestorePolicy == QState::RestoreProperties) { evaluated: globalRestorePolicy == QState::RestoreProperties| yes Evaluation Count:54 | yes Evaluation Count:43 |
| 43-54 |
| 578 | if (assn.explicitlySet) { evaluated: assn.explicitlySet| yes Evaluation Count:36 | yes Evaluation Count:18 |
| 18-36 |
| 579 | if (!hasRestorable(s, assn.object, assn.propertyName)) { evaluated: !hasRestorable(s, assn.object, assn.propertyName)| yes Evaluation Count:34 | yes Evaluation Count:2 |
| 2-34 |
| 580 | QVariant value = savedValueForRestorable(exitedStates_sorted, assn.object, assn.propertyName); executed (the execution status of this line is deduced): QVariant value = savedValueForRestorable(exitedStates_sorted, assn.object, assn.propertyName); | - |
| 581 | unregisterRestorables(exitedStates_sorted, assn.object, assn.propertyName); executed (the execution status of this line is deduced): unregisterRestorables(exitedStates_sorted, assn.object, assn.propertyName); | - |
| 582 | registerRestorable(s, assn.object, assn.propertyName, value); executed (the execution status of this line is deduced): registerRestorable(s, assn.object, assn.propertyName, value); | - |
| 583 | } executed: }Execution Count:34 | 34 |
| 584 | } else { executed: }Execution Count:36 | 36 |
| 585 | // The property is being restored, hence no need to | - |
| 586 | // save the current value. Discard any saved values in | - |
| 587 | // exited states, since those are now stale. | - |
| 588 | unregisterRestorables(exitedStates_sorted, assn.object, assn.propertyName); executed (the execution status of this line is deduced): unregisterRestorables(exitedStates_sorted, assn.object, assn.propertyName); | - |
| 589 | } executed: }Execution Count:18 | 18 |
| 590 | } | - |
| 591 | assn.write(); executed (the execution status of this line is deduced): assn.write(); | - |
| 592 | } executed: }Execution Count:97 | 97 |
| 593 | } | - |
| 594 | | - |
| 595 | QAbstractStatePrivate::get(s)->callOnEntry(event); executed (the execution status of this line is deduced): QAbstractStatePrivate::get(s)->callOnEntry(event); | - |
| 596 | QAbstractStatePrivate::get(s)->emitEntered(); executed (the execution status of this line is deduced): QAbstractStatePrivate::get(s)->emitEntered(); | - |
| 597 | if (statesForDefaultEntry.contains(s)) { evaluated: statesForDefaultEntry.contains(s)| yes Evaluation Count:45 | yes Evaluation Count:1397 |
| 45-1397 |
| 598 | // ### executeContent(s.initial.transition.children()) | - |
| 599 | } executed: }Execution Count:45 | 45 |
| 600 | | - |
| 601 | // Emit propertiesAssigned signal if the state has no animated properties. | - |
| 602 | { | - |
| 603 | QState *ss = toStandardState(s); executed (the execution status of this line is deduced): QState *ss = toStandardState(s); | - |
| 604 | if (ss evaluated: ss| yes Evaluation Count:1372 | yes Evaluation Count:70 |
| 70-1372 |
| 605 | #ifndef QT_NO_ANIMATION executed (the execution status of this line is deduced): | - |
| 606 | && !animationsForState.contains(s) evaluated: !animationsForState.contains(s)| yes Evaluation Count:1340 | yes Evaluation Count:32 |
| 32-1340 |
| 607 | #endif | - |
| 608 | ) | - |
| 609 | QStatePrivate::get(ss)->emitPropertiesAssigned(); executed: QStatePrivate::get(ss)->emitPropertiesAssigned();Execution Count:1340 | 1340 |
| 610 | } | - |
| 611 | | - |
| 612 | if (isFinal(s)) { evaluated: isFinal(s)| yes Evaluation Count:70 | yes Evaluation Count:1372 |
| 70-1372 |
| 613 | QState *parent = s->parentState(); executed (the execution status of this line is deduced): QState *parent = s->parentState(); | - |
| 614 | if (parent) { partially evaluated: parent| yes Evaluation Count:70 | no Evaluation Count:0 |
| 0-70 |
| 615 | if (parent != rootState()) { evaluated: parent != rootState()| yes Evaluation Count:8 | yes Evaluation Count:62 |
| 8-62 |
| 616 | #ifdef QSTATEMACHINE_DEBUG | - |
| 617 | qDebug() << q << ": emitting finished signal for" << parent; | - |
| 618 | #endif | - |
| 619 | QStatePrivate::get(parent)->emitFinished(); executed (the execution status of this line is deduced): QStatePrivate::get(parent)->emitFinished(); | - |
| 620 | } executed: }Execution Count:8 | 8 |
| 621 | QState *grandparent = parent->parentState(); executed (the execution status of this line is deduced): QState *grandparent = parent->parentState(); | - |
| 622 | if (grandparent && isParallel(grandparent)) { evaluated: grandparent| yes Evaluation Count:11 | yes Evaluation Count:59 |
evaluated: isParallel(grandparent)| yes Evaluation Count:7 | yes Evaluation Count:4 |
| 4-59 |
| 623 | bool allChildStatesFinal = true; executed (the execution status of this line is deduced): bool allChildStatesFinal = true; | - |
| 624 | QList<QAbstractState*> childStates = QStatePrivate::get(grandparent)->childStates(); executed (the execution status of this line is deduced): QList<QAbstractState*> childStates = QStatePrivate::get(grandparent)->childStates(); | - |
| 625 | for (int j = 0; j < childStates.size(); ++j) { evaluated: j < childStates.size()| yes Evaluation Count:16 | yes Evaluation Count:3 |
| 3-16 |
| 626 | QAbstractState *cs = childStates.at(j); executed (the execution status of this line is deduced): QAbstractState *cs = childStates.at(j); | - |
| 627 | if (!isInFinalState(cs)) { evaluated: !isInFinalState(cs)| yes Evaluation Count:4 | yes Evaluation Count:12 |
| 4-12 |
| 628 | allChildStatesFinal = false; executed (the execution status of this line is deduced): allChildStatesFinal = false; | - |
| 629 | break; executed: break;Execution Count:4 | 4 |
| 630 | } | - |
| 631 | } executed: }Execution Count:12 | 12 |
| 632 | if (allChildStatesFinal && (grandparent != rootState())) { evaluated: allChildStatesFinal| yes Evaluation Count:3 | yes Evaluation Count:4 |
evaluated: (grandparent != rootState())| yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-4 |
| 633 | #ifdef QSTATEMACHINE_DEBUG | - |
| 634 | qDebug() << q << ": emitting finished signal for" << grandparent; | - |
| 635 | #endif | - |
| 636 | QStatePrivate::get(grandparent)->emitFinished(); executed (the execution status of this line is deduced): QStatePrivate::get(grandparent)->emitFinished(); | - |
| 637 | } executed: }Execution Count:2 | 2 |
| 638 | } executed: }Execution Count:7 | 7 |
| 639 | } executed: }Execution Count:70 | 70 |
| 640 | } executed: }Execution Count:70 | 70 |
| 641 | } executed: }Execution Count:1442 | 1442 |
| 642 | { | - |
| 643 | QSet<QAbstractState*>::const_iterator it; executed (the execution status of this line is deduced): QSet<QAbstractState*>::const_iterator it; | - |
| 644 | for (it = configuration.constBegin(); it != configuration.constEnd(); ++it) { evaluated: it != configuration.constEnd()| yes Evaluation Count:1502 | yes Evaluation Count:1304 |
| 1304-1502 |
| 645 | if (isFinal(*it)) { evaluated: isFinal(*it)| yes Evaluation Count:72 | yes Evaluation Count:1430 |
| 72-1430 |
| 646 | QState *parent = (*it)->parentState(); executed (the execution status of this line is deduced): QState *parent = (*it)->parentState(); | - |
| 647 | if (((parent == rootState()) evaluated: (parent == rootState())| yes Evaluation Count:62 | yes Evaluation Count:10 |
| 10-62 |
| 648 | && (rootState()->childMode() == QState::ExclusiveStates)) partially evaluated: (rootState()->childMode() == QState::ExclusiveStates)| yes Evaluation Count:62 | no Evaluation Count:0 |
| 0-62 |
| 649 | || ((parent->parentState() == rootState()) evaluated: (parent->parentState() == rootState())| yes Evaluation Count:2 | yes Evaluation Count:8 |
| 2-8 |
| 650 | && (rootState()->childMode() == QState::ParallelStates) evaluated: (rootState()->childMode() == QState::ParallelStates)| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
| 651 | && isInFinalState(rootState()))) { partially evaluated: isInFinalState(rootState())| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 652 | processing = false; executed (the execution status of this line is deduced): processing = false; | - |
| 653 | stopProcessingReason = Finished; executed (the execution status of this line is deduced): stopProcessingReason = Finished; | - |
| 654 | break; executed: break;Execution Count:63 | 63 |
| 655 | } | - |
| 656 | } executed: }Execution Count:9 | 9 |
| 657 | } executed: }Execution Count:1439 | 1439 |
| 658 | } | - |
| 659 | // qDebug() << "configuration:" << configuration.toList(); | - |
| 660 | } executed: }Execution Count:1367 | 1367 |
| 661 | | - |
| 662 | void QStateMachinePrivate::addStatesToEnter(QAbstractState *s, QState *root, | - |
| 663 | QSet<QAbstractState*> &statesToEnter, | - |
| 664 | QSet<QAbstractState*> &statesForDefaultEntry) | - |
| 665 | { | - |
| 666 | if (QHistoryState *h = toHistoryState(s)) { evaluated: QHistoryState *h = toHistoryState(s)| yes Evaluation Count:12 | yes Evaluation Count:1425 |
| 12-1425 |
| 667 | QList<QAbstractState*> hconf = QHistoryStatePrivate::get(h)->configuration; executed (the execution status of this line is deduced): QList<QAbstractState*> hconf = QHistoryStatePrivate::get(h)->configuration; | - |
| 668 | if (!hconf.isEmpty()) { evaluated: !hconf.isEmpty()| yes Evaluation Count:6 | yes Evaluation Count:6 |
| 6 |
| 669 | for (int k = 0; k < hconf.size(); ++k) { evaluated: k < hconf.size()| yes Evaluation Count:6 | yes Evaluation Count:6 |
| 6 |
| 670 | QAbstractState *s0 = hconf.at(k); executed (the execution status of this line is deduced): QAbstractState *s0 = hconf.at(k); | - |
| 671 | addStatesToEnter(s0, root, statesToEnter, statesForDefaultEntry); executed (the execution status of this line is deduced): addStatesToEnter(s0, root, statesToEnter, statesForDefaultEntry); | - |
| 672 | } executed: }Execution Count:6 | 6 |
| 673 | #ifdef QSTATEMACHINE_DEBUG | - |
| 674 | qDebug() <<q_func() << ": restoring" | - |
| 675 | << ((QHistoryStatePrivate::get(h)->historyType == QHistoryState::DeepHistory) ? "deep" : "shallow") | - |
| 676 | << "history from" << s << ':' << hconf; | - |
| 677 | #endif | - |
| 678 | } else { executed: }Execution Count:6 | 6 |
| 679 | QList<QAbstractState*> hlst; executed (the execution status of this line is deduced): QList<QAbstractState*> hlst; | - |
| 680 | if (QHistoryStatePrivate::get(h)->defaultState) evaluated: QHistoryStatePrivate::get(h)->defaultState| yes Evaluation Count:5 | yes Evaluation Count:1 |
| 1-5 |
| 681 | hlst.append(QHistoryStatePrivate::get(h)->defaultState); executed: hlst.append(QHistoryStatePrivate::get(h)->defaultState);Execution Count:5 | 5 |
| 682 | | - |
| 683 | if (hlst.isEmpty()) { evaluated: hlst.isEmpty()| yes Evaluation Count:1 | yes Evaluation Count:5 |
| 1-5 |
| 684 | setError(QStateMachine::NoDefaultStateInHistoryStateError, h); executed (the execution status of this line is deduced): setError(QStateMachine::NoDefaultStateInHistoryStateError, h); | - |
| 685 | } else { executed: }Execution Count:1 | 1 |
| 686 | for (int k = 0; k < hlst.size(); ++k) { evaluated: k < hlst.size()| yes Evaluation Count:5 | yes Evaluation Count:5 |
| 5 |
| 687 | QAbstractState *s0 = hlst.at(k); executed (the execution status of this line is deduced): QAbstractState *s0 = hlst.at(k); | - |
| 688 | addStatesToEnter(s0, root, statesToEnter, statesForDefaultEntry); executed (the execution status of this line is deduced): addStatesToEnter(s0, root, statesToEnter, statesForDefaultEntry); | - |
| 689 | } executed: }Execution Count:5 | 5 |
| 690 | #ifdef QSTATEMACHINE_DEBUG | - |
| 691 | qDebug() << q_func() << ": initial history targets for" << s << ':' << hlst; | - |
| 692 | #endif | - |
| 693 | } executed: }Execution Count:5 | 5 |
| 694 | } | - |
| 695 | } else { | - |
| 696 | if (s == rootState()) { evaluated: s == rootState()| yes Evaluation Count:1 | yes Evaluation Count:1424 |
| 1-1424 |
| 697 | // Error has already been set by exitStates(). | - |
| 698 | Q_ASSERT(error != QStateMachine::NoError); executed (the execution status of this line is deduced): qt_noop(); | - |
| 699 | return; executed: return;Execution Count:1 | 1 |
| 700 | } | - |
| 701 | statesToEnter.insert(s); executed (the execution status of this line is deduced): statesToEnter.insert(s); | - |
| 702 | if (isParallel(s)) { evaluated: isParallel(s)| yes Evaluation Count:6 | yes Evaluation Count:1418 |
| 6-1418 |
| 703 | QState *grp = toStandardState(s); executed (the execution status of this line is deduced): QState *grp = toStandardState(s); | - |
| 704 | QList<QAbstractState*> lst = QStatePrivate::get(grp)->childStates(); executed (the execution status of this line is deduced): QList<QAbstractState*> lst = QStatePrivate::get(grp)->childStates(); | - |
| 705 | for (int i = 0; i < lst.size(); ++i) { evaluated: i < lst.size()| yes Evaluation Count:11 | yes Evaluation Count:6 |
| 6-11 |
| 706 | QAbstractState *child = lst.at(i); executed (the execution status of this line is deduced): QAbstractState *child = lst.at(i); | - |
| 707 | addStatesToEnter(child, grp, statesToEnter, statesForDefaultEntry); executed (the execution status of this line is deduced): addStatesToEnter(child, grp, statesToEnter, statesForDefaultEntry); | - |
| 708 | } executed: }Execution Count:11 | 11 |
| 709 | } else if (isCompound(s)) { executed: }Execution Count:6 evaluated: isCompound(s)| yes Evaluation Count:54 | yes Evaluation Count:1364 |
| 6-1364 |
| 710 | statesForDefaultEntry.insert(s); executed (the execution status of this line is deduced): statesForDefaultEntry.insert(s); | - |
| 711 | QState *grp = toStandardState(s); executed (the execution status of this line is deduced): QState *grp = toStandardState(s); | - |
| 712 | QAbstractState *initial = grp->initialState(); executed (the execution status of this line is deduced): QAbstractState *initial = grp->initialState(); | - |
| 713 | if (initial != 0) { evaluated: initial != 0| yes Evaluation Count:38 | yes Evaluation Count:16 |
| 16-38 |
| 714 | Q_ASSERT(initial->machine() == q_func()); executed (the execution status of this line is deduced): qt_noop(); | - |
| 715 | addStatesToEnter(initial, grp, statesToEnter, statesForDefaultEntry); executed (the execution status of this line is deduced): addStatesToEnter(initial, grp, statesToEnter, statesForDefaultEntry); | - |
| 716 | } else { executed: }Execution Count:38 | 38 |
| 717 | setError(QStateMachine::NoInitialStateError, grp); executed (the execution status of this line is deduced): setError(QStateMachine::NoInitialStateError, grp); | - |
| 718 | return; executed: return;Execution Count:16 | 16 |
| 719 | } | - |
| 720 | } | - |
| 721 | } | - |
| 722 | } | - |
| 723 | | - |
| 724 | void QStateMachinePrivate::addAncestorStatesToEnter(QAbstractState *s, QState *root, | - |
| 725 | QSet<QAbstractState*> &statesToEnter, | - |
| 726 | QSet<QAbstractState*> &statesForDefaultEntry) | - |
| 727 | { | - |
| 728 | QList<QState*> ancs = properAncestors(s, root); executed (the execution status of this line is deduced): QList<QState*> ancs = properAncestors(s, root); | - |
| 729 | for (int i = 0; i < ancs.size(); ++i) { evaluated: i < ancs.size()| yes Evaluation Count:31 | yes Evaluation Count:1376 |
| 31-1376 |
| 730 | QState *anc = ancs.at(i); executed (the execution status of this line is deduced): QState *anc = ancs.at(i); | - |
| 731 | if (!anc->parentState()) partially evaluated: !anc->parentState()| no Evaluation Count:0 | yes Evaluation Count:31 |
| 0-31 |
| 732 | continue; never executed: continue; | 0 |
| 733 | statesToEnter.insert(anc); executed (the execution status of this line is deduced): statesToEnter.insert(anc); | - |
| 734 | if (isParallel(anc)) { evaluated: isParallel(anc)| yes Evaluation Count:2 | yes Evaluation Count:29 |
| 2-29 |
| 735 | QList<QAbstractState*> lst = QStatePrivate::get(anc)->childStates(); executed (the execution status of this line is deduced): QList<QAbstractState*> lst = QStatePrivate::get(anc)->childStates(); | - |
| 736 | for (int j = 0; j < lst.size(); ++j) { evaluated: j < lst.size()| yes Evaluation Count:4 | yes Evaluation Count:2 |
| 2-4 |
| 737 | QAbstractState *child = lst.at(j); executed (the execution status of this line is deduced): QAbstractState *child = lst.at(j); | - |
| 738 | bool hasDescendantInList = false; executed (the execution status of this line is deduced): bool hasDescendantInList = false; | - |
| 739 | QSet<QAbstractState*>::const_iterator it; executed (the execution status of this line is deduced): QSet<QAbstractState*>::const_iterator it; | - |
| 740 | for (it = statesToEnter.constBegin(); it != statesToEnter.constEnd(); ++it) { partially evaluated: it != statesToEnter.constEnd()| yes Evaluation Count:14 | no Evaluation Count:0 |
| 0-14 |
| 741 | if (isDescendantOf(*it, child)) { evaluated: isDescendantOf(*it, child)| yes Evaluation Count:4 | yes Evaluation Count:10 |
| 4-10 |
| 742 | hasDescendantInList = true; executed (the execution status of this line is deduced): hasDescendantInList = true; | - |
| 743 | break; executed: break;Execution Count:4 | 4 |
| 744 | } | - |
| 745 | } executed: }Execution Count:10 | 10 |
| 746 | if (!hasDescendantInList) partially evaluated: !hasDescendantInList| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 747 | addStatesToEnter(child, anc, statesToEnter, statesForDefaultEntry); never executed: addStatesToEnter(child, anc, statesToEnter, statesForDefaultEntry); | 0 |
| 748 | } executed: }Execution Count:4 | 4 |
| 749 | } executed: }Execution Count:2 | 2 |
| 750 | } executed: }Execution Count:31 | 31 |
| 751 | } executed: }Execution Count:1376 | 1376 |
| 752 | | - |
| 753 | bool QStateMachinePrivate::isFinal(const QAbstractState *s) | - |
| 754 | { | - |
| 755 | return s && (QAbstractStatePrivate::get(s)->stateType == QAbstractStatePrivate::FinalState); executed: return s && (QAbstractStatePrivate::get(s)->stateType == QAbstractStatePrivate::FinalState);Execution Count:3302 | 3302 |
| 756 | } | - |
| 757 | | - |
| 758 | bool QStateMachinePrivate::isParallel(const QAbstractState *s) | - |
| 759 | { | - |
| 760 | const QState *ss = toStandardState(s); executed (the execution status of this line is deduced): const QState *ss = toStandardState(s); | - |
| 761 | return ss && (QStatePrivate::get(ss)->childMode == QState::ParallelStates); executed: return ss && (QStatePrivate::get(ss)->childMode == QState::ParallelStates);Execution Count:4195 | 4195 |
| 762 | } | - |
| 763 | | - |
| 764 | bool QStateMachinePrivate::isCompound(const QAbstractState *s) const | - |
| 765 | { | - |
| 766 | const QState *group = toStandardState(s); executed (the execution status of this line is deduced): const QState *group = toStandardState(s); | - |
| 767 | if (!group) evaluated: !group| yes Evaluation Count:70 | yes Evaluation Count:1367 |
| 70-1367 |
| 768 | return false; executed: return false;Execution Count:70 | 70 |
| 769 | bool isMachine = QStatePrivate::get(group)->isMachine; executed (the execution status of this line is deduced): bool isMachine = QStatePrivate::get(group)->isMachine; | - |
| 770 | // Don't treat the machine as compound if it's a sub-state of this machine | - |
| 771 | if (isMachine && (group != rootState())) evaluated: isMachine| yes Evaluation Count:4 | yes Evaluation Count:1363 |
evaluated: (group != rootState())| yes Evaluation Count:3 | yes Evaluation Count:1 |
| 1-1363 |
| 772 | return false; executed: return false;Execution Count:3 | 3 |
| 773 | return (!isParallel(group) && !QStatePrivate::get(group)->childStates().isEmpty()); executed: return (!isParallel(group) && !QStatePrivate::get(group)->childStates().isEmpty());Execution Count:1364 | 1364 |
| 774 | } | - |
| 775 | | - |
| 776 | bool QStateMachinePrivate::isAtomic(const QAbstractState *s) const | - |
| 777 | { | - |
| 778 | const QState *ss = toStandardState(s); executed (the execution status of this line is deduced): const QState *ss = toStandardState(s); | - |
| 779 | return (ss && QStatePrivate::get(ss)->childStates().isEmpty()) executed: return (ss && QStatePrivate::get(ss)->childStates().isEmpty()) || isFinal(s) || (ss && QStatePrivate::get(ss)->isMachine && (ss != rootState()));Execution Count:5038 | 5038 |
| 780 | || isFinal(s) executed: return (ss && QStatePrivate::get(ss)->childStates().isEmpty()) || isFinal(s) || (ss && QStatePrivate::get(ss)->isMachine && (ss != rootState()));Execution Count:5038 | 5038 |
| 781 | // Treat the machine as atomic if it's a sub-state of this machine executed: return (ss && QStatePrivate::get(ss)->childStates().isEmpty()) || isFinal(s) || (ss && QStatePrivate::get(ss)->isMachine && (ss != rootState()));Execution Count:5038 | 5038 |
| 782 | || (ss && QStatePrivate::get(ss)->isMachine && (ss != rootState())); executed: return (ss && QStatePrivate::get(ss)->childStates().isEmpty()) || isFinal(s) || (ss && QStatePrivate::get(ss)->isMachine && (ss != rootState()));Execution Count:5038 | 5038 |
| 783 | } | - |
| 784 | | - |
| 785 | | - |
| 786 | bool QStateMachinePrivate::isDescendantOf(const QAbstractState *state, const QAbstractState *other) | - |
| 787 | { | - |
| 788 | Q_ASSERT(state != 0); executed (the execution status of this line is deduced): qt_noop(); | - |
| 789 | for (QAbstractState *s = state->parentState(); s != 0; s = s->parentState()) { evaluated: s != 0| yes Evaluation Count:4830 | yes Evaluation Count:343 |
| 343-4830 |
| 790 | if (s == other) evaluated: s == other| yes Evaluation Count:3990 | yes Evaluation Count:840 |
| 840-3990 |
| 791 | return true; executed: return true;Execution Count:3990 | 3990 |
| 792 | } executed: }Execution Count:840 | 840 |
| 793 | return false; executed: return false;Execution Count:343 | 343 |
| 794 | } | - |
| 795 | | - |
| 796 | QList<QState*> QStateMachinePrivate::properAncestors(const QAbstractState *state, const QState *upperBound) | - |
| 797 | { | - |
| 798 | Q_ASSERT(state != 0); executed (the execution status of this line is deduced): qt_noop(); | - |
| 799 | QList<QState*> result; executed (the execution status of this line is deduced): QList<QState*> result; | - |
| 800 | for (QState *s = state->parentState(); s && s != upperBound; s = s->parentState()) { evaluated: s| yes Evaluation Count:9316 | yes Evaluation Count:7373 |
evaluated: s != upperBound| yes Evaluation Count:7925 | yes Evaluation Count:1391 |
| 1391-9316 |
| 801 | result.append(s); executed (the execution status of this line is deduced): result.append(s); | - |
| 802 | } executed: }Execution Count:7925 | 7925 |
| 803 | return result; executed: return result;Execution Count:8764 | 8764 |
| 804 | } | - |
| 805 | | - |
| 806 | QState *QStateMachinePrivate::toStandardState(QAbstractState *state) | - |
| 807 | { | - |
| 808 | if (state && (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::StandardState)) partially evaluated: state| yes Evaluation Count:10478 | no Evaluation Count:0 |
evaluated: (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::StandardState)| yes Evaluation Count:10243 | yes Evaluation Count:235 |
| 0-10478 |
| 809 | return static_cast<QState*>(state); executed: return static_cast<QState*>(state);Execution Count:10243 | 10243 |
| 810 | return 0; executed: return 0;Execution Count:235 | 235 |
| 811 | } | - |
| 812 | | - |
| 813 | const QState *QStateMachinePrivate::toStandardState(const QAbstractState *state) | - |
| 814 | { | - |
| 815 | if (state && (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::StandardState)) evaluated: state| yes Evaluation Count:10667 | yes Evaluation Count:3 |
evaluated: (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::StandardState)| yes Evaluation Count:10506 | yes Evaluation Count:161 |
| 3-10667 |
| 816 | return static_cast<const QState*>(state); executed: return static_cast<const QState*>(state);Execution Count:10506 | 10506 |
| 817 | return 0; executed: return 0;Execution Count:164 | 164 |
| 818 | } | - |
| 819 | | - |
| 820 | QFinalState *QStateMachinePrivate::toFinalState(QAbstractState *state) | - |
| 821 | { | - |
| 822 | if (state && (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::FinalState)) never evaluated: state never evaluated: (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::FinalState) | 0 |
| 823 | return static_cast<QFinalState*>(state); never executed: return static_cast<QFinalState*>(state); | 0 |
| 824 | return 0; never executed: return 0; | 0 |
| 825 | } | - |
| 826 | | - |
| 827 | QHistoryState *QStateMachinePrivate::toHistoryState(QAbstractState *state) | - |
| 828 | { | - |
| 829 | if (state && (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::HistoryState)) partially evaluated: state| yes Evaluation Count:1437 | no Evaluation Count:0 |
evaluated: (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::HistoryState)| yes Evaluation Count:12 | yes Evaluation Count:1425 |
| 0-1437 |
| 830 | return static_cast<QHistoryState*>(state); executed: return static_cast<QHistoryState*>(state);Execution Count:12 | 12 |
| 831 | return 0; executed: return 0;Execution Count:1425 | 1425 |
| 832 | } | - |
| 833 | | - |
| 834 | bool QStateMachinePrivate::isInFinalState(QAbstractState* s) const | - |
| 835 | { | - |
| 836 | if (isCompound(s)) { evaluated: isCompound(s)| yes Evaluation Count:18 | yes Evaluation Count:1 |
| 1-18 |
| 837 | QState *grp = toStandardState(s); executed (the execution status of this line is deduced): QState *grp = toStandardState(s); | - |
| 838 | QList<QAbstractState*> lst = QStatePrivate::get(grp)->childStates(); executed (the execution status of this line is deduced): QList<QAbstractState*> lst = QStatePrivate::get(grp)->childStates(); | - |
| 839 | for (int i = 0; i < lst.size(); ++i) { evaluated: i < lst.size()| yes Evaluation Count:30 | yes Evaluation Count:4 |
| 4-30 |
| 840 | QAbstractState *cs = lst.at(i); executed (the execution status of this line is deduced): QAbstractState *cs = lst.at(i); | - |
| 841 | if (isFinal(cs) && configuration.contains(cs)) evaluated: isFinal(cs)| yes Evaluation Count:18 | yes Evaluation Count:12 |
evaluated: configuration.contains(cs)| yes Evaluation Count:14 | yes Evaluation Count:4 |
| 4-18 |
| 842 | return true; executed: return true;Execution Count:14 | 14 |
| 843 | } executed: }Execution Count:16 | 16 |
| 844 | return false; executed: return false;Execution Count:4 | 4 |
| 845 | } else if (isParallel(s)) { partially evaluated: isParallel(s)| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 846 | QState *grp = toStandardState(s); executed (the execution status of this line is deduced): QState *grp = toStandardState(s); | - |
| 847 | QList<QAbstractState*> lst = QStatePrivate::get(grp)->childStates(); executed (the execution status of this line is deduced): QList<QAbstractState*> lst = QStatePrivate::get(grp)->childStates(); | - |
| 848 | for (int i = 0; i < lst.size(); ++i) { evaluated: i < lst.size()| yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
| 849 | QAbstractState *cs = lst.at(i); executed (the execution status of this line is deduced): QAbstractState *cs = lst.at(i); | - |
| 850 | if (!isInFinalState(cs)) partially evaluated: !isInFinalState(cs)| no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
| 851 | return false; never executed: return false; | 0 |
| 852 | } executed: }Execution Count:2 | 2 |
| 853 | return true; executed: return true;Execution Count:1 | 1 |
| 854 | } | - |
| 855 | else | - |
| 856 | return false; never executed: return false; | 0 |
| 857 | } | - |
| 858 | | - |
| 859 | #ifndef QT_NO_PROPERTIES | - |
| 860 | | - |
| 861 | /*! | - |
| 862 | \internal | - |
| 863 | Returns true if the given state has saved the value of the given property, | - |
| 864 | otherwise returns false. | - |
| 865 | */ | - |
| 866 | bool QStateMachinePrivate::hasRestorable(QAbstractState *state, QObject *object, | - |
| 867 | const QByteArray &propertyName) const | - |
| 868 | { | - |
| 869 | RestorableId id(object, propertyName); executed (the execution status of this line is deduced): RestorableId id(object, propertyName); | - |
| 870 | return registeredRestorablesForState.value(state).contains(id); executed: return registeredRestorablesForState.value(state).contains(id);Execution Count:48 | 48 |
| 871 | } | - |
| 872 | | - |
| 873 | /*! | - |
| 874 | \internal | - |
| 875 | Returns the value to save for the property identified by \a id. | - |
| 876 | If an exited state (member of \a exitedStates_sorted) has saved a value for | - |
| 877 | the property, the saved value from the last (outermost) state that will be | - |
| 878 | exited is returned (in practice carrying the saved value on to the next | - |
| 879 | state). Otherwise, the current value of the property is returned. | - |
| 880 | */ | - |
| 881 | QVariant QStateMachinePrivate::savedValueForRestorable(const QList<QAbstractState*> &exitedStates_sorted, | - |
| 882 | QObject *object, const QByteArray &propertyName) const | - |
| 883 | { | - |
| 884 | #ifdef QSTATEMACHINE_RESTORE_PROPERTIES_DEBUG | - |
| 885 | qDebug() << q_func() << ": savedValueForRestorable(" << exitedStates_sorted << object << propertyName << ")"; | - |
| 886 | #endif | - |
| 887 | RestorableId id(object, propertyName); executed (the execution status of this line is deduced): RestorableId id(object, propertyName); | - |
| 888 | for (int i = exitedStates_sorted.size() - 1; i >= 0; --i) { evaluated: i >= 0| yes Evaluation Count:38 | yes Evaluation Count:29 |
| 29-38 |
| 889 | QAbstractState *s = exitedStates_sorted.at(i); executed (the execution status of this line is deduced): QAbstractState *s = exitedStates_sorted.at(i); | - |
| 890 | QHash<RestorableId, QVariant> restorables = registeredRestorablesForState.value(s); executed (the execution status of this line is deduced): QHash<RestorableId, QVariant> restorables = registeredRestorablesForState.value(s); | - |
| 891 | QHash<RestorableId, QVariant>::const_iterator it = restorables.constFind(id); executed (the execution status of this line is deduced): QHash<RestorableId, QVariant>::const_iterator it = restorables.constFind(id); | - |
| 892 | if (it != restorables.constEnd()) { evaluated: it != restorables.constEnd()| yes Evaluation Count:17 | yes Evaluation Count:21 |
| 17-21 |
| 893 | #ifdef QSTATEMACHINE_RESTORE_PROPERTIES_DEBUG | - |
| 894 | qDebug() << q_func() << ": using" << it.value() << "from" << s; | - |
| 895 | #endif | - |
| 896 | return it.value(); executed: return it.value();Execution Count:17 | 17 |
| 897 | } | - |
| 898 | } executed: }Execution Count:21 | 21 |
| 899 | #ifdef QSTATEMACHINE_RESTORE_PROPERTIES_DEBUG | - |
| 900 | qDebug() << q_func() << ": falling back to current value"; | - |
| 901 | #endif | - |
| 902 | return id.first->property(id.second); executed: return id.first->property(id.second);Execution Count:29 | 29 |
| 903 | } | - |
| 904 | | - |
| 905 | void QStateMachinePrivate::registerRestorable(QAbstractState *state, QObject *object, const QByteArray &propertyName, | - |
| 906 | const QVariant &value) | - |
| 907 | { | - |
| 908 | #ifdef QSTATEMACHINE_RESTORE_PROPERTIES_DEBUG | - |
| 909 | qDebug() << q_func() << ": registerRestorable(" << state << object << propertyName << value << ")"; | - |
| 910 | #endif | - |
| 911 | RestorableId id(object, propertyName); executed (the execution status of this line is deduced): RestorableId id(object, propertyName); | - |
| 912 | QHash<RestorableId, QVariant> &restorables = registeredRestorablesForState[state]; executed (the execution status of this line is deduced): QHash<RestorableId, QVariant> &restorables = registeredRestorablesForState[state]; | - |
| 913 | if (!restorables.contains(id)) partially evaluated: !restorables.contains(id)| yes Evaluation Count:46 | no Evaluation Count:0 |
| 0-46 |
| 914 | restorables.insert(id, value); executed: restorables.insert(id, value);Execution Count:46 | 46 |
| 915 | #ifdef QSTATEMACHINE_RESTORE_PROPERTIES_DEBUG | - |
| 916 | else | - |
| 917 | qDebug() << q_func() << ": (already registered)"; | - |
| 918 | #endif | - |
| 919 | } executed: }Execution Count:46 | 46 |
| 920 | | - |
| 921 | void QStateMachinePrivate::unregisterRestorables(const QList<QAbstractState *> &states, QObject *object, | - |
| 922 | const QByteArray &propertyName) | - |
| 923 | { | - |
| 924 | #ifdef QSTATEMACHINE_RESTORE_PROPERTIES_DEBUG | - |
| 925 | qDebug() << q_func() << ": unregisterRestorables(" << states << object << propertyName << ")"; | - |
| 926 | #endif | - |
| 927 | RestorableId id(object, propertyName); executed (the execution status of this line is deduced): RestorableId id(object, propertyName); | - |
| 928 | for (int i = 0; i < states.size(); ++i) { evaluated: i < states.size()| yes Evaluation Count:70 | yes Evaluation Count:65 |
| 65-70 |
| 929 | QAbstractState *s = states.at(i); executed (the execution status of this line is deduced): QAbstractState *s = states.at(i); | - |
| 930 | QHash<QAbstractState*, QHash<RestorableId, QVariant> >::iterator it; executed (the execution status of this line is deduced): QHash<QAbstractState*, QHash<RestorableId, QVariant> >::iterator it; | - |
| 931 | it = registeredRestorablesForState.find(s); executed (the execution status of this line is deduced): it = registeredRestorablesForState.find(s); | - |
| 932 | if (it == registeredRestorablesForState.end()) evaluated: it == registeredRestorablesForState.end()| yes Evaluation Count:24 | yes Evaluation Count:46 |
| 24-46 |
| 933 | continue; executed: continue;Execution Count:24 | 24 |
| 934 | QHash<RestorableId, QVariant> &restorables = it.value(); executed (the execution status of this line is deduced): QHash<RestorableId, QVariant> &restorables = it.value(); | - |
| 935 | QHash<RestorableId, QVariant>::iterator it2; executed (the execution status of this line is deduced): QHash<RestorableId, QVariant>::iterator it2; | - |
| 936 | it2 = restorables.find(id); executed (the execution status of this line is deduced): it2 = restorables.find(id); | - |
| 937 | if (it2 == restorables.end()) evaluated: it2 == restorables.end()| yes Evaluation Count:9 | yes Evaluation Count:37 |
| 9-37 |
| 938 | continue; executed: continue;Execution Count:9 | 9 |
| 939 | #ifdef QSTATEMACHINE_RESTORE_PROPERTIES_DEBUG | - |
| 940 | qDebug() << q_func() << ": unregistered for" << s; | - |
| 941 | #endif | - |
| 942 | restorables.erase(it2); executed (the execution status of this line is deduced): restorables.erase(it2); | - |
| 943 | if (restorables.isEmpty()) evaluated: restorables.isEmpty()| yes Evaluation Count:32 | yes Evaluation Count:5 |
| 5-32 |
| 944 | registeredRestorablesForState.erase(it); executed: registeredRestorablesForState.erase(it);Execution Count:32 | 32 |
| 945 | } executed: }Execution Count:37 | 37 |
| 946 | } executed: }Execution Count:65 | 65 |
| 947 | | - |
| 948 | QList<QPropertyAssignment> QStateMachinePrivate::restorablesToPropertyList(const QHash<RestorableId, QVariant> &restorables) const | - |
| 949 | { | - |
| 950 | QList<QPropertyAssignment> result; executed (the execution status of this line is deduced): QList<QPropertyAssignment> result; | - |
| 951 | QHash<RestorableId, QVariant>::const_iterator it; executed (the execution status of this line is deduced): QHash<RestorableId, QVariant>::const_iterator it; | - |
| 952 | for (it = restorables.constBegin(); it != restorables.constEnd(); ++it) { evaluated: it != restorables.constEnd()| yes Evaluation Count:25 | yes Evaluation Count:23 |
| 23-25 |
| 953 | if (!it.key().first) { evaluated: !it.key().first| yes Evaluation Count:1 | yes Evaluation Count:24 |
| 1-24 |
| 954 | // Property object was deleted | - |
| 955 | continue; executed: continue;Execution Count:1 | 1 |
| 956 | } | - |
| 957 | #ifdef QSTATEMACHINE_RESTORE_PROPERTIES_DEBUG | - |
| 958 | qDebug() << q_func() << ": restoring" << it.key().first << it.key().second << "to" << it.value(); | - |
| 959 | #endif | - |
| 960 | result.append(QPropertyAssignment(it.key().first, it.key().second, it.value(), /*explicitlySet=*/false)); executed (the execution status of this line is deduced): result.append(QPropertyAssignment(it.key().first, it.key().second, it.value(), false)); | - |
| 961 | } executed: }Execution Count:24 | 24 |
| 962 | return result; executed: return result;Execution Count:23 | 23 |
| 963 | } | - |
| 964 | | - |
| 965 | /*! | - |
| 966 | \internal | - |
| 967 | Computes the set of properties whose values should be restored given that | - |
| 968 | the states \a statesToExit_sorted will be exited. | - |
| 969 | | - |
| 970 | If a particular (object, propertyName) pair occurs more than once (i.e., | - |
| 971 | because nested states are being exited), the value from the last (outermost) | - |
| 972 | exited state takes precedence. | - |
| 973 | | - |
| 974 | The result of this function must be filtered according to the explicit | - |
| 975 | property assignments (QState::assignProperty()) of the entered states | - |
| 976 | before the property restoration is actually performed; i.e., if an entered | - |
| 977 | state assigns to a property that would otherwise be restored, that property | - |
| 978 | should not be restored after all, but the saved value from the exited state | - |
| 979 | should be remembered by the entered state (see registerRestorable()). | - |
| 980 | */ | - |
| 981 | QHash<QStateMachinePrivate::RestorableId, QVariant> QStateMachinePrivate::computePendingRestorables( | - |
| 982 | const QList<QAbstractState*> &statesToExit_sorted) const | - |
| 983 | { | - |
| 984 | QHash<QStateMachinePrivate::RestorableId, QVariant> restorables; executed (the execution status of this line is deduced): QHash<QStateMachinePrivate::RestorableId, QVariant> restorables; | - |
| 985 | for (int i = statesToExit_sorted.size() - 1; i >= 0; --i) { evaluated: i >= 0| yes Evaluation Count:1271 | yes Evaluation Count:1224 |
| 1224-1271 |
| 986 | QAbstractState *s = statesToExit_sorted.at(i); executed (the execution status of this line is deduced): QAbstractState *s = statesToExit_sorted.at(i); | - |
| 987 | QHash<QStateMachinePrivate::RestorableId, QVariant> rs = registeredRestorablesForState.value(s); executed (the execution status of this line is deduced): QHash<QStateMachinePrivate::RestorableId, QVariant> rs = registeredRestorablesForState.value(s); | - |
| 988 | QHash<QStateMachinePrivate::RestorableId, QVariant>::const_iterator it; executed (the execution status of this line is deduced): QHash<QStateMachinePrivate::RestorableId, QVariant>::const_iterator it; | - |
| 989 | for (it = rs.constBegin(); it != rs.constEnd(); ++it) { evaluated: it != rs.constEnd()| yes Evaluation Count:39 | yes Evaluation Count:1271 |
| 39-1271 |
| 990 | if (!restorables.contains(it.key())) evaluated: !restorables.contains(it.key())| yes Evaluation Count:38 | yes Evaluation Count:1 |
| 1-38 |
| 991 | restorables.insert(it.key(), it.value()); executed: restorables.insert(it.key(), it.value());Execution Count:38 | 38 |
| 992 | } executed: }Execution Count:39 | 39 |
| 993 | } executed: }Execution Count:1271 | 1271 |
| 994 | return restorables; executed: return restorables;Execution Count:1224 | 1224 |
| 995 | } | - |
| 996 | | - |
| 997 | /*! | - |
| 998 | \internal | - |
| 999 | Computes the ordered sets of property assignments for the states to be | - |
| 1000 | entered, \a statesToEnter_sorted. Also filters \a pendingRestorables (removes | - |
| 1001 | properties that should not be restored because they are assigned by an | - |
| 1002 | entered state). | - |
| 1003 | */ | - |
| 1004 | QHash<QAbstractState*, QList<QPropertyAssignment> > QStateMachinePrivate::computePropertyAssignments( | - |
| 1005 | const QList<QAbstractState*> &statesToEnter_sorted, QHash<RestorableId, QVariant> &pendingRestorables) const | - |
| 1006 | { | - |
| 1007 | QHash<QAbstractState*, QList<QPropertyAssignment> > assignmentsForState; executed (the execution status of this line is deduced): QHash<QAbstractState*, QList<QPropertyAssignment> > assignmentsForState; | - |
| 1008 | for (int i = 0; i < statesToEnter_sorted.size(); ++i) { evaluated: i < statesToEnter_sorted.size()| yes Evaluation Count:1442 | yes Evaluation Count:1367 |
| 1367-1442 |
| 1009 | QState *s = toStandardState(statesToEnter_sorted.at(i)); executed (the execution status of this line is deduced): QState *s = toStandardState(statesToEnter_sorted.at(i)); | - |
| 1010 | if (!s) evaluated: !s| yes Evaluation Count:70 | yes Evaluation Count:1372 |
| 70-1372 |
| 1011 | continue; executed: continue;Execution Count:70 | 70 |
| 1012 | | - |
| 1013 | QList<QPropertyAssignment> &assignments = QStatePrivate::get(s)->propertyAssignments; executed (the execution status of this line is deduced): QList<QPropertyAssignment> &assignments = QStatePrivate::get(s)->propertyAssignments; | - |
| 1014 | for (int j = 0; j < assignments.size(); ++j) { evaluated: j < assignments.size()| yes Evaluation Count:110 | yes Evaluation Count:1372 |
| 110-1372 |
| 1015 | const QPropertyAssignment &assn = assignments.at(j); executed (the execution status of this line is deduced): const QPropertyAssignment &assn = assignments.at(j); | - |
| 1016 | if (assn.objectDeleted()) { evaluated: assn.objectDeleted()| yes Evaluation Count:1 | yes Evaluation Count:109 |
| 1-109 |
| 1017 | assignments.removeAt(j--); executed (the execution status of this line is deduced): assignments.removeAt(j--); | - |
| 1018 | } else { executed: }Execution Count:1 | 1 |
| 1019 | pendingRestorables.remove(RestorableId(assn.object, assn.propertyName)); executed (the execution status of this line is deduced): pendingRestorables.remove(RestorableId(assn.object, assn.propertyName)); | - |
| 1020 | assignmentsForState[s].append(assn); executed (the execution status of this line is deduced): assignmentsForState[s].append(assn); | - |
| 1021 | } executed: }Execution Count:109 | 109 |
| 1022 | } | - |
| 1023 | } executed: }Execution Count:1372 | 1372 |
| 1024 | return assignmentsForState; executed: return assignmentsForState;Execution Count:1367 | 1367 |
| 1025 | } | - |
| 1026 | | - |
| 1027 | #endif // QT_NO_PROPERTIES | - |
| 1028 | | - |
| 1029 | QAbstractState *QStateMachinePrivate::findErrorState(QAbstractState *context) | - |
| 1030 | { | - |
| 1031 | // Find error state recursively in parent hierarchy if not set explicitly for context state | - |
| 1032 | QAbstractState *errorState = 0; executed (the execution status of this line is deduced): QAbstractState *errorState = 0; | - |
| 1033 | if (context != 0) { evaluated: context != 0| yes Evaluation Count:40 | yes Evaluation Count:9 |
| 9-40 |
| 1034 | QState *s = toStandardState(context); executed (the execution status of this line is deduced): QState *s = toStandardState(context); | - |
| 1035 | if (s != 0) evaluated: s != 0| yes Evaluation Count:39 | yes Evaluation Count:1 |
| 1-39 |
| 1036 | errorState = s->errorState(); executed: errorState = s->errorState();Execution Count:39 | 39 |
| 1037 | | - |
| 1038 | if (errorState == 0) evaluated: errorState == 0| yes Evaluation Count:29 | yes Evaluation Count:11 |
| 11-29 |
| 1039 | errorState = findErrorState(context->parentState()); executed: errorState = findErrorState(context->parentState());Execution Count:29 | 29 |
| 1040 | } executed: }Execution Count:40 | 40 |
| 1041 | | - |
| 1042 | return errorState; executed: return errorState;Execution Count:49 | 49 |
| 1043 | } | - |
| 1044 | | - |
| 1045 | void QStateMachinePrivate::setError(QStateMachine::Error errorCode, QAbstractState *currentContext) | - |
| 1046 | { | - |
| 1047 | Q_Q(QStateMachine); executed (the execution status of this line is deduced): QStateMachine * const q = q_func(); | - |
| 1048 | | - |
| 1049 | error = errorCode; executed (the execution status of this line is deduced): error = errorCode; | - |
| 1050 | switch (errorCode) { | - |
| 1051 | case QStateMachine::NoInitialStateError: | - |
| 1052 | Q_ASSERT(currentContext != 0); executed (the execution status of this line is deduced): qt_noop(); | - |
| 1053 | | - |
| 1054 | errorString = QStateMachine::tr("Missing initial state in compound state '%1'") executed (the execution status of this line is deduced): errorString = QStateMachine::tr("Missing initial state in compound state '%1'") | - |
| 1055 | .arg(currentContext->objectName()); executed (the execution status of this line is deduced): .arg(currentContext->objectName()); | - |
| 1056 | | - |
| 1057 | break; executed: break;Execution Count:16 | 16 |
| 1058 | case QStateMachine::NoDefaultStateInHistoryStateError: | - |
| 1059 | Q_ASSERT(currentContext != 0); executed (the execution status of this line is deduced): qt_noop(); | - |
| 1060 | | - |
| 1061 | errorString = QStateMachine::tr("Missing default state in history state '%1'") executed (the execution status of this line is deduced): errorString = QStateMachine::tr("Missing default state in history state '%1'") | - |
| 1062 | .arg(currentContext->objectName()); executed (the execution status of this line is deduced): .arg(currentContext->objectName()); | - |
| 1063 | break; executed: break;Execution Count:1 | 1 |
| 1064 | | - |
| 1065 | case QStateMachine::NoCommonAncestorForTransitionError: | - |
| 1066 | Q_ASSERT(currentContext != 0); executed (the execution status of this line is deduced): qt_noop(); | - |
| 1067 | | - |
| 1068 | errorString = QStateMachine::tr("No common ancestor for targets and source of transition from state '%1'") executed (the execution status of this line is deduced): errorString = QStateMachine::tr("No common ancestor for targets and source of transition from state '%1'") | - |
| 1069 | .arg(currentContext->objectName()); executed (the execution status of this line is deduced): .arg(currentContext->objectName()); | - |
| 1070 | break; executed: break;Execution Count:3 | 3 |
| 1071 | default: | - |
| 1072 | errorString = QStateMachine::tr("Unknown error"); never executed (the execution status of this line is deduced): errorString = QStateMachine::tr("Unknown error"); | - |
| 1073 | }; | 0 |
| 1074 | | - |
| 1075 | pendingErrorStates.clear(); executed (the execution status of this line is deduced): pendingErrorStates.clear(); | - |
| 1076 | pendingErrorStatesForDefaultEntry.clear(); executed (the execution status of this line is deduced): pendingErrorStatesForDefaultEntry.clear(); | - |
| 1077 | | - |
| 1078 | QAbstractState *currentErrorState = findErrorState(currentContext); executed (the execution status of this line is deduced): QAbstractState *currentErrorState = findErrorState(currentContext); | - |
| 1079 | | - |
| 1080 | // Avoid infinite loop if the error state itself has an error | - |
| 1081 | if (currentContext == currentErrorState) evaluated: currentContext == currentErrorState| yes Evaluation Count:1 | yes Evaluation Count:19 |
| 1-19 |
| 1082 | currentErrorState = 0; executed: currentErrorState = 0;Execution Count:1 | 1 |
| 1083 | | - |
| 1084 | Q_ASSERT(currentErrorState != rootState()); executed (the execution status of this line is deduced): qt_noop(); | - |
| 1085 | | - |
| 1086 | if (currentErrorState != 0) { evaluated: currentErrorState != 0| yes Evaluation Count:10 | yes Evaluation Count:10 |
| 10 |
| 1087 | QState *lca = findLCA(QList<QAbstractState*>() << currentErrorState << currentContext); executed (the execution status of this line is deduced): QState *lca = findLCA(QList<QAbstractState*>() << currentErrorState << currentContext); | - |
| 1088 | addStatesToEnter(currentErrorState, lca, pendingErrorStates, pendingErrorStatesForDefaultEntry); executed (the execution status of this line is deduced): addStatesToEnter(currentErrorState, lca, pendingErrorStates, pendingErrorStatesForDefaultEntry); | - |
| 1089 | addAncestorStatesToEnter(currentErrorState, lca, pendingErrorStates, pendingErrorStatesForDefaultEntry); executed (the execution status of this line is deduced): addAncestorStatesToEnter(currentErrorState, lca, pendingErrorStates, pendingErrorStatesForDefaultEntry); | - |
| 1090 | } else { executed: }Execution Count:10 | 10 |
| 1091 | qWarning("Unrecoverable error detected in running state machine: %s", executed (the execution status of this line is deduced): QMessageLogger("statemachine/qstatemachine.cpp", 1091, __PRETTY_FUNCTION__).warning("Unrecoverable error detected in running state machine: %s", | - |
| 1092 | qPrintable(errorString)); executed (the execution status of this line is deduced): QString(errorString).toLocal8Bit().constData()); | - |
| 1093 | q->stop(); executed (the execution status of this line is deduced): q->stop(); | - |
| 1094 | } executed: }Execution Count:10 | 10 |
| 1095 | } | - |
| 1096 | | - |
| 1097 | #ifndef QT_NO_ANIMATION | - |
| 1098 | | - |
| 1099 | QPair<QList<QAbstractAnimation*>, QList<QAbstractAnimation*> > | - |
| 1100 | QStateMachinePrivate::initializeAnimation(QAbstractAnimation *abstractAnimation, | - |
| 1101 | const QPropertyAssignment &prop) | - |
| 1102 | { | - |
| 1103 | QList<QAbstractAnimation*> handledAnimations; executed (the execution status of this line is deduced): QList<QAbstractAnimation*> handledAnimations; | - |
| 1104 | QList<QAbstractAnimation*> localResetEndValues; executed (the execution status of this line is deduced): QList<QAbstractAnimation*> localResetEndValues; | - |
| 1105 | QAnimationGroup *group = qobject_cast<QAnimationGroup*>(abstractAnimation); executed (the execution status of this line is deduced): QAnimationGroup *group = qobject_cast<QAnimationGroup*>(abstractAnimation); | - |
| 1106 | if (group) { evaluated: group| yes Evaluation Count:5 | yes Evaluation Count:50 |
| 5-50 |
| 1107 | for (int i = 0; i < group->animationCount(); ++i) { evaluated: i < group->animationCount()| yes Evaluation Count:8 | yes Evaluation Count:5 |
| 5-8 |
| 1108 | QAbstractAnimation *animationChild = group->animationAt(i); executed (the execution status of this line is deduced): QAbstractAnimation *animationChild = group->animationAt(i); | - |
| 1109 | QPair<QList<QAbstractAnimation*>, QList<QAbstractAnimation*> > ret; executed (the execution status of this line is deduced): QPair<QList<QAbstractAnimation*>, QList<QAbstractAnimation*> > ret; | - |
| 1110 | ret = initializeAnimation(animationChild, prop); executed (the execution status of this line is deduced): ret = initializeAnimation(animationChild, prop); | - |
| 1111 | handledAnimations << ret.first; executed (the execution status of this line is deduced): handledAnimations << ret.first; | - |
| 1112 | localResetEndValues << ret.second; executed (the execution status of this line is deduced): localResetEndValues << ret.second; | - |
| 1113 | } executed: }Execution Count:8 | 8 |
| 1114 | } else { executed: }Execution Count:5 | 5 |
| 1115 | QPropertyAnimation *animation = qobject_cast<QPropertyAnimation *>(abstractAnimation); executed (the execution status of this line is deduced): QPropertyAnimation *animation = qobject_cast<QPropertyAnimation *>(abstractAnimation); | - |
| 1116 | if (animation != 0 partially evaluated: animation != 0| yes Evaluation Count:50 | no Evaluation Count:0 |
| 0-50 |
| 1117 | && prop.object == animation->targetObject() evaluated: prop.object == animation->targetObject()| yes Evaluation Count:46 | yes Evaluation Count:4 |
| 4-46 |
| 1118 | && prop.propertyName == animation->propertyName()) { evaluated: prop.propertyName == animation->propertyName()| yes Evaluation Count:36 | yes Evaluation Count:10 |
| 10-36 |
| 1119 | | - |
| 1120 | // Only change end value if it is undefined | - |
| 1121 | if (!animation->endValue().isValid()) { evaluated: !animation->endValue().isValid()| yes Evaluation Count:35 | yes Evaluation Count:1 |
| 1-35 |
| 1122 | animation->setEndValue(prop.value); executed (the execution status of this line is deduced): animation->setEndValue(prop.value); | - |
| 1123 | localResetEndValues.append(animation); executed (the execution status of this line is deduced): localResetEndValues.append(animation); | - |
| 1124 | } executed: }Execution Count:35 | 35 |
| 1125 | handledAnimations.append(animation); executed (the execution status of this line is deduced): handledAnimations.append(animation); | - |
| 1126 | } executed: }Execution Count:36 | 36 |
| 1127 | } executed: }Execution Count:50 | 50 |
| 1128 | return qMakePair(handledAnimations, localResetEndValues); executed: return qMakePair(handledAnimations, localResetEndValues);Execution Count:55 | 55 |
| 1129 | } | - |
| 1130 | | - |
| 1131 | void QStateMachinePrivate::_q_animationFinished() | - |
| 1132 | { | - |
| 1133 | Q_Q(QStateMachine); executed (the execution status of this line is deduced): QStateMachine * const q = q_func(); | - |
| 1134 | QAbstractAnimation *anim = qobject_cast<QAbstractAnimation*>(q->sender()); executed (the execution status of this line is deduced): QAbstractAnimation *anim = qobject_cast<QAbstractAnimation*>(q->sender()); | - |
| 1135 | Q_ASSERT(anim != 0); executed (the execution status of this line is deduced): qt_noop(); | - |
| 1136 | QObject::disconnect(anim, SIGNAL(finished()), q, SLOT(_q_animationFinished())); executed (the execution status of this line is deduced): QObject::disconnect(anim, "2""finished()", q, "1""_q_animationFinished()"); | - |
| 1137 | if (resetAnimationEndValues.contains(anim)) { partially evaluated: resetAnimationEndValues.contains(anim)| yes Evaluation Count:15 | no Evaluation Count:0 |
| 0-15 |
| 1138 | qobject_cast<QVariantAnimation*>(anim)->setEndValue(QVariant()); // ### generalize executed (the execution status of this line is deduced): qobject_cast<QVariantAnimation*>(anim)->setEndValue(QVariant()); | - |
| 1139 | resetAnimationEndValues.remove(anim); executed (the execution status of this line is deduced): resetAnimationEndValues.remove(anim); | - |
| 1140 | } executed: }Execution Count:15 | 15 |
| 1141 | | - |
| 1142 | QAbstractState *state = stateForAnimation.take(anim); executed (the execution status of this line is deduced): QAbstractState *state = stateForAnimation.take(anim); | - |
| 1143 | Q_ASSERT(state != 0); executed (the execution status of this line is deduced): qt_noop(); | - |
| 1144 | | - |
| 1145 | #ifndef QT_NO_PROPERTIES | - |
| 1146 | // Set the final property value. | - |
| 1147 | QPropertyAssignment assn = propertyForAnimation.take(anim); executed (the execution status of this line is deduced): QPropertyAssignment assn = propertyForAnimation.take(anim); | - |
| 1148 | assn.write(); executed (the execution status of this line is deduced): assn.write(); | - |
| 1149 | if (!assn.explicitlySet) evaluated: !assn.explicitlySet| yes Evaluation Count:1 | yes Evaluation Count:14 |
| 1-14 |
| 1150 | unregisterRestorables(QList<QAbstractState*>() << state, assn.object, assn.propertyName); executed: unregisterRestorables(QList<QAbstractState*>() << state, assn.object, assn.propertyName);Execution Count:1 | 1 |
| 1151 | #endif | - |
| 1152 | | - |
| 1153 | QHash<QAbstractState*, QList<QAbstractAnimation*> >::iterator it; executed (the execution status of this line is deduced): QHash<QAbstractState*, QList<QAbstractAnimation*> >::iterator it; | - |
| 1154 | it = animationsForState.find(state); executed (the execution status of this line is deduced): it = animationsForState.find(state); | - |
| 1155 | Q_ASSERT(it != animationsForState.end()); executed (the execution status of this line is deduced): qt_noop(); | - |
| 1156 | QList<QAbstractAnimation*> &animations = it.value(); executed (the execution status of this line is deduced): QList<QAbstractAnimation*> &animations = it.value(); | - |
| 1157 | animations.removeOne(anim); executed (the execution status of this line is deduced): animations.removeOne(anim); | - |
| 1158 | if (animations.isEmpty()) { evaluated: animations.isEmpty()| yes Evaluation Count:12 | yes Evaluation Count:3 |
| 3-12 |
| 1159 | animationsForState.erase(it); executed (the execution status of this line is deduced): animationsForState.erase(it); | - |
| 1160 | QStatePrivate::get(toStandardState(state))->emitPropertiesAssigned(); executed (the execution status of this line is deduced): QStatePrivate::get(toStandardState(state))->emitPropertiesAssigned(); | - |
| 1161 | } executed: }Execution Count:12 | 12 |
| 1162 | } executed: }Execution Count:15 | 15 |
| 1163 | | - |
| 1164 | QList<QAbstractAnimation *> QStateMachinePrivate::selectAnimations(const QList<QAbstractTransition *> &transitionList) const | - |
| 1165 | { | - |
| 1166 | QList<QAbstractAnimation *> selectedAnimations; executed (the execution status of this line is deduced): QList<QAbstractAnimation *> selectedAnimations; | - |
| 1167 | if (animated) { partially evaluated: animated| yes Evaluation Count:1367 | no Evaluation Count:0 |
| 0-1367 |
| 1168 | for (int i = 0; i < transitionList.size(); ++i) { evaluated: i < transitionList.size()| yes Evaluation Count:1368 | yes Evaluation Count:1367 |
| 1367-1368 |
| 1169 | QAbstractTransition *transition = transitionList.at(i); executed (the execution status of this line is deduced): QAbstractTransition *transition = transitionList.at(i); | - |
| 1170 | | - |
| 1171 | selectedAnimations << transition->animations(); executed (the execution status of this line is deduced): selectedAnimations << transition->animations(); | - |
| 1172 | selectedAnimations << defaultAnimationsForSource.values(transition->sourceState()); executed (the execution status of this line is deduced): selectedAnimations << defaultAnimationsForSource.values(transition->sourceState()); | - |
| 1173 | | - |
| 1174 | QList<QAbstractState *> targetStates = transition->targetStates(); executed (the execution status of this line is deduced): QList<QAbstractState *> targetStates = transition->targetStates(); | - |
| 1175 | for (int j=0; j<targetStates.size(); ++j) evaluated: j<targetStates.size()| yes Evaluation Count:1366 | yes Evaluation Count:1368 |
| 1366-1368 |
| 1176 | selectedAnimations << defaultAnimationsForTarget.values(targetStates.at(j)); executed: selectedAnimations << defaultAnimationsForTarget.values(targetStates.at(j));Execution Count:1366 | 1366 |
| 1177 | } executed: }Execution Count:1368 | 1368 |
| 1178 | selectedAnimations << defaultAnimations; executed (the execution status of this line is deduced): selectedAnimations << defaultAnimations; | - |
| 1179 | } executed: }Execution Count:1367 | 1367 |
| 1180 | return selectedAnimations; executed: return selectedAnimations;Execution Count:1367 | 1367 |
| 1181 | } | - |
| 1182 | | - |
| 1183 | void QStateMachinePrivate::terminateActiveAnimations(QAbstractState *state, | - |
| 1184 | const QHash<QAbstractState*, QList<QPropertyAssignment> > &assignmentsForEnteredStates) | - |
| 1185 | { | - |
| 1186 | Q_Q(QStateMachine); executed (the execution status of this line is deduced): QStateMachine * const q = q_func(); | - |
| 1187 | QList<QAbstractAnimation*> animations = animationsForState.take(state); executed (the execution status of this line is deduced): QList<QAbstractAnimation*> animations = animationsForState.take(state); | - |
| 1188 | for (int i = 0; i < animations.size(); ++i) { evaluated: i < animations.size()| yes Evaluation Count:20 | yes Evaluation Count:1271 |
| 20-1271 |
| 1189 | QAbstractAnimation *anim = animations.at(i); executed (the execution status of this line is deduced): QAbstractAnimation *anim = animations.at(i); | - |
| 1190 | QObject::disconnect(anim, SIGNAL(finished()), q, SLOT(_q_animationFinished())); executed (the execution status of this line is deduced): QObject::disconnect(anim, "2""finished()", q, "1""_q_animationFinished()"); | - |
| 1191 | stateForAnimation.remove(anim); executed (the execution status of this line is deduced): stateForAnimation.remove(anim); | - |
| 1192 | | - |
| 1193 | // Stop the (top-level) animation. | - |
| 1194 | // ### Stopping nested animation has weird behavior. | - |
| 1195 | QAbstractAnimation *topLevelAnim = anim; executed (the execution status of this line is deduced): QAbstractAnimation *topLevelAnim = anim; | - |
| 1196 | while (QAnimationGroup *group = topLevelAnim->group()) partially evaluated: QAnimationGroup *group = topLevelAnim->group()| no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
| 1197 | topLevelAnim = group; never executed: topLevelAnim = group; | 0 |
| 1198 | topLevelAnim->stop(); executed (the execution status of this line is deduced): topLevelAnim->stop(); | - |
| 1199 | | - |
| 1200 | if (resetAnimationEndValues.contains(anim)) { evaluated: resetAnimationEndValues.contains(anim)| yes Evaluation Count:19 | yes Evaluation Count:1 |
| 1-19 |
| 1201 | qobject_cast<QVariantAnimation*>(anim)->setEndValue(QVariant()); // ### generalize executed (the execution status of this line is deduced): qobject_cast<QVariantAnimation*>(anim)->setEndValue(QVariant()); | - |
| 1202 | resetAnimationEndValues.remove(anim); executed (the execution status of this line is deduced): resetAnimationEndValues.remove(anim); | - |
| 1203 | } executed: }Execution Count:19 | 19 |
| 1204 | QPropertyAssignment assn = propertyForAnimation.take(anim); executed (the execution status of this line is deduced): QPropertyAssignment assn = propertyForAnimation.take(anim); | - |
| 1205 | Q_ASSERT(assn.object != 0); executed (the execution status of this line is deduced): qt_noop(); | - |
| 1206 | // If there is no property assignment that sets this property, | - |
| 1207 | // set the property to its target value. | - |
| 1208 | bool found = false; executed (the execution status of this line is deduced): bool found = false; | - |
| 1209 | QHash<QAbstractState*, QList<QPropertyAssignment> >::const_iterator it; executed (the execution status of this line is deduced): QHash<QAbstractState*, QList<QPropertyAssignment> >::const_iterator it; | - |
| 1210 | for (it = assignmentsForEnteredStates.constBegin(); it != assignmentsForEnteredStates.constEnd(); ++it) { evaluated: it != assignmentsForEnteredStates.constEnd()| yes Evaluation Count:18 | yes Evaluation Count:20 |
| 18-20 |
| 1211 | const QList<QPropertyAssignment> &assignments = it.value(); executed (the execution status of this line is deduced): const QList<QPropertyAssignment> &assignments = it.value(); | - |
| 1212 | for (int j = 0; j < assignments.size(); ++j) { evaluated: j < assignments.size()| yes Evaluation Count:18 | yes Evaluation Count:8 |
| 8-18 |
| 1213 | if (assignments.at(j).hasTarget(assn.object, assn.propertyName)) { evaluated: assignments.at(j).hasTarget(assn.object, assn.propertyName)| yes Evaluation Count:10 | yes Evaluation Count:8 |
| 8-10 |
| 1214 | found = true; executed (the execution status of this line is deduced): found = true; | - |
| 1215 | break; executed: break;Execution Count:10 | 10 |
| 1216 | } | - |
| 1217 | } executed: }Execution Count:8 | 8 |
| 1218 | } executed: }Execution Count:18 | 18 |
| 1219 | if (!found) { evaluated: !found| yes Evaluation Count:10 | yes Evaluation Count:10 |
| 10 |
| 1220 | assn.write(); executed (the execution status of this line is deduced): assn.write(); | - |
| 1221 | if (!assn.explicitlySet) partially evaluated: !assn.explicitlySet| no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
| 1222 | unregisterRestorables(QList<QAbstractState*>() << state, assn.object, assn.propertyName); never executed: unregisterRestorables(QList<QAbstractState*>() << state, assn.object, assn.propertyName); | 0 |
| 1223 | } executed: }Execution Count:10 | 10 |
| 1224 | } executed: }Execution Count:20 | 20 |
| 1225 | } executed: }Execution Count:1271 | 1271 |
| 1226 | | - |
| 1227 | void QStateMachinePrivate::initializeAnimations(QAbstractState *state, const QList<QAbstractAnimation *> &selectedAnimations, | - |
| 1228 | const QList<QAbstractState*> &exitedStates_sorted, | - |
| 1229 | QHash<QAbstractState*, QList<QPropertyAssignment> > &assignmentsForEnteredStates) | - |
| 1230 | { | - |
| 1231 | Q_Q(QStateMachine); executed (the execution status of this line is deduced): QStateMachine * const q = q_func(); | - |
| 1232 | if (!assignmentsForEnteredStates.contains(state)) evaluated: !assignmentsForEnteredStates.contains(state)| yes Evaluation Count:1327 | yes Evaluation Count:115 |
| 115-1327 |
| 1233 | return; executed: return;Execution Count:1327 | 1327 |
| 1234 | QList<QPropertyAssignment> &assignments = assignmentsForEnteredStates[state]; executed (the execution status of this line is deduced): QList<QPropertyAssignment> &assignments = assignmentsForEnteredStates[state]; | - |
| 1235 | for (int i = 0; i < selectedAnimations.size(); ++i) { evaluated: i < selectedAnimations.size()| yes Evaluation Count:41 | yes Evaluation Count:85 |
| 41-85 |
| 1236 | QAbstractAnimation *anim = selectedAnimations.at(i); executed (the execution status of this line is deduced): QAbstractAnimation *anim = selectedAnimations.at(i); | - |
| 1237 | QList<QPropertyAssignment>::iterator it; executed (the execution status of this line is deduced): QList<QPropertyAssignment>::iterator it; | - |
| 1238 | for (it = assignments.begin(); it != assignments.end(); ) { evaluated: it != assignments.end()| yes Evaluation Count:47 | yes Evaluation Count:41 |
| 41-47 |
| 1239 | QPair<QList<QAbstractAnimation*>, QList<QAbstractAnimation*> > ret; executed (the execution status of this line is deduced): QPair<QList<QAbstractAnimation*>, QList<QAbstractAnimation*> > ret; | - |
| 1240 | const QPropertyAssignment &assn = *it; executed (the execution status of this line is deduced): const QPropertyAssignment &assn = *it; | - |
| 1241 | ret = initializeAnimation(anim, assn); executed (the execution status of this line is deduced): ret = initializeAnimation(anim, assn); | - |
| 1242 | QList<QAbstractAnimation*> handlers = ret.first; executed (the execution status of this line is deduced): QList<QAbstractAnimation*> handlers = ret.first; | - |
| 1243 | if (!handlers.isEmpty()) { evaluated: !handlers.isEmpty()| yes Evaluation Count:36 | yes Evaluation Count:11 |
| 11-36 |
| 1244 | for (int j = 0; j < handlers.size(); ++j) { evaluated: j < handlers.size()| yes Evaluation Count:36 | yes Evaluation Count:36 |
| 36 |
| 1245 | QAbstractAnimation *a = handlers.at(j); executed (the execution status of this line is deduced): QAbstractAnimation *a = handlers.at(j); | - |
| 1246 | propertyForAnimation.insert(a, assn); executed (the execution status of this line is deduced): propertyForAnimation.insert(a, assn); | - |
| 1247 | stateForAnimation.insert(a, state); executed (the execution status of this line is deduced): stateForAnimation.insert(a, state); | - |
| 1248 | animationsForState[state].append(a); executed (the execution status of this line is deduced): animationsForState[state].append(a); | - |
| 1249 | // ### connect to just the top-level animation? | - |
| 1250 | QObject::connect(a, SIGNAL(finished()), q, SLOT(_q_animationFinished()), Qt::UniqueConnection); executed (the execution status of this line is deduced): QObject::connect(a, "2""finished()", q, "1""_q_animationFinished()", Qt::UniqueConnection); | - |
| 1251 | } executed: }Execution Count:36 | 36 |
| 1252 | if ((globalRestorePolicy == QState::RestoreProperties) evaluated: (globalRestorePolicy == QState::RestoreProperties)| yes Evaluation Count:12 | yes Evaluation Count:24 |
| 12-24 |
| 1253 | && !hasRestorable(state, assn.object, assn.propertyName)) { partially evaluated: !hasRestorable(state, assn.object, assn.propertyName)| yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-12 |
| 1254 | QVariant value = savedValueForRestorable(exitedStates_sorted, assn.object, assn.propertyName); executed (the execution status of this line is deduced): QVariant value = savedValueForRestorable(exitedStates_sorted, assn.object, assn.propertyName); | - |
| 1255 | unregisterRestorables(exitedStates_sorted, assn.object, assn.propertyName); executed (the execution status of this line is deduced): unregisterRestorables(exitedStates_sorted, assn.object, assn.propertyName); | - |
| 1256 | registerRestorable(state, assn.object, assn.propertyName, value); executed (the execution status of this line is deduced): registerRestorable(state, assn.object, assn.propertyName, value); | - |
| 1257 | } executed: }Execution Count:12 | 12 |
| 1258 | it = assignments.erase(it); executed (the execution status of this line is deduced): it = assignments.erase(it); | - |
| 1259 | } else { executed: }Execution Count:36 | 36 |
| 1260 | ++it; executed (the execution status of this line is deduced): ++it; | - |
| 1261 | } executed: }Execution Count:11 | 11 |
| 1262 | for (int j = 0; j < ret.second.size(); ++j) evaluated: j < ret.second.size()| yes Evaluation Count:35 | yes Evaluation Count:47 |
| 35-47 |
| 1263 | resetAnimationEndValues.insert(ret.second.at(j)); executed: resetAnimationEndValues.insert(ret.second.at(j));Execution Count:35 | 35 |
| 1264 | } executed: }Execution Count:47 | 47 |
| 1265 | // We require that at least one animation is valid. | - |
| 1266 | // ### generalize | - |
| 1267 | QList<QVariantAnimation*> variantAnims = anim->findChildren<QVariantAnimation*>(); executed (the execution status of this line is deduced): QList<QVariantAnimation*> variantAnims = anim->findChildren<QVariantAnimation*>(); | - |
| 1268 | if (QVariantAnimation *va = qobject_cast<QVariantAnimation*>(anim)) evaluated: QVariantAnimation *va = qobject_cast<QVariantAnimation*>(anim)| yes Evaluation Count:38 | yes Evaluation Count:3 |
| 3-38 |
| 1269 | variantAnims.append(va); executed: variantAnims.append(va);Execution Count:38 | 38 |
| 1270 | | - |
| 1271 | bool hasValidEndValue = false; executed (the execution status of this line is deduced): bool hasValidEndValue = false; | - |
| 1272 | for (int j = 0; j < variantAnims.size(); ++j) { evaluated: j < variantAnims.size()| yes Evaluation Count:41 | yes Evaluation Count:2 |
| 2-41 |
| 1273 | if (variantAnims.at(j)->endValue().isValid()) { evaluated: variantAnims.at(j)->endValue().isValid()| yes Evaluation Count:39 | yes Evaluation Count:2 |
| 2-39 |
| 1274 | hasValidEndValue = true; executed (the execution status of this line is deduced): hasValidEndValue = true; | - |
| 1275 | break; executed: break;Execution Count:39 | 39 |
| 1276 | } | - |
| 1277 | } executed: }Execution Count:2 | 2 |
| 1278 | | - |
| 1279 | if (hasValidEndValue) { evaluated: hasValidEndValue| yes Evaluation Count:39 | yes Evaluation Count:2 |
| 2-39 |
| 1280 | if (anim->state() == QAbstractAnimation::Running) { evaluated: anim->state() == QAbstractAnimation::Running| yes Evaluation Count:5 | yes Evaluation Count:34 |
| 5-34 |
| 1281 | // The animation is still running. This can happen if the | - |
| 1282 | // animation is a group, and one of its children just finished, | - |
| 1283 | // and that caused a state to emit its propertiesAssigned() signal, and | - |
| 1284 | // that triggered a transition in the machine. | - |
| 1285 | // Just stop the animation so it is correctly restarted again. | - |
| 1286 | anim->stop(); executed (the execution status of this line is deduced): anim->stop(); | - |
| 1287 | } executed: }Execution Count:5 | 5 |
| 1288 | anim->start(); executed (the execution status of this line is deduced): anim->start(); | - |
| 1289 | } executed: }Execution Count:39 | 39 |
| 1290 | | - |
| 1291 | if (assignments.isEmpty()) { evaluated: assignments.isEmpty()| yes Evaluation Count:30 | yes Evaluation Count:11 |
| 11-30 |
| 1292 | assignmentsForEnteredStates.remove(state); executed (the execution status of this line is deduced): assignmentsForEnteredStates.remove(state); | - |
| 1293 | break; executed: break;Execution Count:30 | 30 |
| 1294 | } | - |
| 1295 | } executed: }Execution Count:11 | 11 |
| 1296 | } executed: }Execution Count:115 | 115 |
| 1297 | | - |
| 1298 | #endif // !QT_NO_ANIMATION | - |
| 1299 | | - |
| 1300 | QAbstractTransition *QStateMachinePrivate::createInitialTransition() const | - |
| 1301 | { | - |
| 1302 | class InitialTransition : public QAbstractTransition executed (the execution status of this line is deduced): class InitialTransition : public QAbstractTransition | - |
| 1303 | { executed (the execution status of this line is deduced): { | - |
| 1304 | public: executed (the execution status of this line is deduced): public: | - |
| 1305 | InitialTransition(const QList<QAbstractState *> &targets) executed (the execution status of this line is deduced): InitialTransition(const QList<QAbstractState *> &targets) | - |
| 1306 | : QAbstractTransition() executed (the execution status of this line is deduced): : QAbstractTransition() | - |
| 1307 | { setTargetStates(targets); } executed: }Execution Count:143 | 143 |
| 1308 | protected: executed (the execution status of this line is deduced): protected: | - |
| 1309 | virtual bool eventTest(QEvent *) { return true; } never executed: return true; | 0 |
| 1310 | virtual void onTransition(QEvent *) {} executed (the execution status of this line is deduced): virtual void onTransition(QEvent *) {} | - |
| 1311 | }; executed (the execution status of this line is deduced): }; | - |
| 1312 | | - |
| 1313 | QState *root = rootState(); executed (the execution status of this line is deduced): QState *root = rootState(); | - |
| 1314 | Q_ASSERT(root != 0); executed (the execution status of this line is deduced): qt_noop(); | - |
| 1315 | QList<QAbstractState *> targets; executed (the execution status of this line is deduced): QList<QAbstractState *> targets; | - |
| 1316 | switch (root->childMode()) { | - |
| 1317 | case QState::ExclusiveStates: | - |
| 1318 | targets.append(root->initialState()); executed (the execution status of this line is deduced): targets.append(root->initialState()); | - |
| 1319 | break; executed: break;Execution Count:142 | 142 |
| 1320 | case QState::ParallelStates: | - |
| 1321 | targets = QStatePrivate::get(root)->childStates(); executed (the execution status of this line is deduced): targets = QStatePrivate::get(root)->childStates(); | - |
| 1322 | break; executed: break;Execution Count:1 | 1 |
| 1323 | } | - |
| 1324 | return new InitialTransition(targets); executed: return new InitialTransition(targets);Execution Count:143 | 143 |
| 1325 | } | - |
| 1326 | | - |
| 1327 | void QStateMachinePrivate::clearHistory() | - |
| 1328 | { | - |
| 1329 | Q_Q(QStateMachine); executed (the execution status of this line is deduced): QStateMachine * const q = q_func(); | - |
| 1330 | QList<QHistoryState*> historyStates = q->findChildren<QHistoryState*>(); executed (the execution status of this line is deduced): QList<QHistoryState*> historyStates = q->findChildren<QHistoryState*>(); | - |
| 1331 | for (int i = 0; i < historyStates.size(); ++i) { evaluated: i < historyStates.size()| yes Evaluation Count:8 | yes Evaluation Count:143 |
| 8-143 |
| 1332 | QHistoryState *h = historyStates.at(i); executed (the execution status of this line is deduced): QHistoryState *h = historyStates.at(i); | - |
| 1333 | QHistoryStatePrivate::get(h)->configuration.clear(); executed (the execution status of this line is deduced): QHistoryStatePrivate::get(h)->configuration.clear(); | - |
| 1334 | } executed: }Execution Count:8 | 8 |
| 1335 | } executed: }Execution Count:143 | 143 |
| 1336 | | - |
| 1337 | /*! | - |
| 1338 | \internal | - |
| 1339 | | - |
| 1340 | Registers all signal transitions whose sender object lives in another thread. | - |
| 1341 | | - |
| 1342 | Normally, signal transitions are lazily registered (when a state becomes | - |
| 1343 | active). But if the sender is in a different thread, the transition must be | - |
| 1344 | registered early to keep the state machine from "dropping" signals; e.g., | - |
| 1345 | a second (transition-bound) signal could be emitted on the sender thread | - |
| 1346 | before the state machine gets to process the first signal. | - |
| 1347 | */ | - |
| 1348 | void QStateMachinePrivate::registerMultiThreadedSignalTransitions() | - |
| 1349 | { | - |
| 1350 | Q_Q(QStateMachine); executed (the execution status of this line is deduced): QStateMachine * const q = q_func(); | - |
| 1351 | QList<QSignalTransition*> transitions = rootState()->findChildren<QSignalTransition*>(); executed (the execution status of this line is deduced): QList<QSignalTransition*> transitions = rootState()->findChildren<QSignalTransition*>(); | - |
| 1352 | for (int i = 0; i < transitions.size(); ++i) { evaluated: i < transitions.size()| yes Evaluation Count:68 | yes Evaluation Count:143 |
| 68-143 |
| 1353 | QSignalTransition *t = transitions.at(i); executed (the execution status of this line is deduced): QSignalTransition *t = transitions.at(i); | - |
| 1354 | if ((t->machine() == q) && t->senderObject() && (t->senderObject()->thread() != q->thread())) evaluated: (t->machine() == q)| yes Evaluation Count:65 | yes Evaluation Count:3 |
evaluated: t->senderObject()| yes Evaluation Count:64 | yes Evaluation Count:1 |
evaluated: (t->senderObject()->thread() != q->thread())| yes Evaluation Count:7 | yes Evaluation Count:57 |
| 1-65 |
| 1355 | registerSignalTransition(t); executed: registerSignalTransition(t);Execution Count:7 | 7 |
| 1356 | } executed: }Execution Count:68 | 68 |
| 1357 | } executed: }Execution Count:143 | 143 |
| 1358 | | - |
| 1359 | void QStateMachinePrivate::_q_start() | - |
| 1360 | { | - |
| 1361 | Q_Q(QStateMachine); executed (the execution status of this line is deduced): QStateMachine * const q = q_func(); | - |
| 1362 | Q_ASSERT(state == Starting); executed (the execution status of this line is deduced): qt_noop(); | - |
| 1363 | configuration.clear(); executed (the execution status of this line is deduced): configuration.clear(); | - |
| 1364 | qDeleteAll(internalEventQueue); executed (the execution status of this line is deduced): qDeleteAll(internalEventQueue); | - |
| 1365 | internalEventQueue.clear(); executed (the execution status of this line is deduced): internalEventQueue.clear(); | - |
| 1366 | qDeleteAll(externalEventQueue); executed (the execution status of this line is deduced): qDeleteAll(externalEventQueue); | - |
| 1367 | externalEventQueue.clear(); executed (the execution status of this line is deduced): externalEventQueue.clear(); | - |
| 1368 | clearHistory(); executed (the execution status of this line is deduced): clearHistory(); | - |
| 1369 | | - |
| 1370 | registerMultiThreadedSignalTransitions(); executed (the execution status of this line is deduced): registerMultiThreadedSignalTransitions(); | - |
| 1371 | | - |
| 1372 | #ifdef QSTATEMACHINE_DEBUG | - |
| 1373 | qDebug() << q << ": starting"; | - |
| 1374 | #endif | - |
| 1375 | state = Running; executed (the execution status of this line is deduced): state = Running; | - |
| 1376 | processingScheduled = true; // we call _q_process() below executed (the execution status of this line is deduced): processingScheduled = true; | - |
| 1377 | | - |
| 1378 | QList<QAbstractTransition*> transitions; executed (the execution status of this line is deduced): QList<QAbstractTransition*> transitions; | - |
| 1379 | QAbstractTransition *initialTransition = createInitialTransition(); executed (the execution status of this line is deduced): QAbstractTransition *initialTransition = createInitialTransition(); | - |
| 1380 | transitions.append(initialTransition); executed (the execution status of this line is deduced): transitions.append(initialTransition); | - |
| 1381 | | - |
| 1382 | QEvent nullEvent(QEvent::None); executed (the execution status of this line is deduced): QEvent nullEvent(QEvent::None); | - |
| 1383 | executeTransitionContent(&nullEvent, transitions); executed (the execution status of this line is deduced): executeTransitionContent(&nullEvent, transitions); | - |
| 1384 | QList<QAbstractState*> exitedStates = QList<QAbstractState*>(); executed (the execution status of this line is deduced): QList<QAbstractState*> exitedStates = QList<QAbstractState*>(); | - |
| 1385 | QSet<QAbstractState*> statesForDefaultEntry; executed (the execution status of this line is deduced): QSet<QAbstractState*> statesForDefaultEntry; | - |
| 1386 | QList<QAbstractState*> enteredStates = computeStatesToEnter(transitions, executed (the execution status of this line is deduced): QList<QAbstractState*> enteredStates = computeStatesToEnter(transitions, | - |
| 1387 | statesForDefaultEntry); executed (the execution status of this line is deduced): statesForDefaultEntry); | - |
| 1388 | QHash<RestorableId, QVariant> pendingRestorables; executed (the execution status of this line is deduced): QHash<RestorableId, QVariant> pendingRestorables; | - |
| 1389 | QHash<QAbstractState*, QList<QPropertyAssignment> > assignmentsForEnteredStates = executed (the execution status of this line is deduced): QHash<QAbstractState*, QList<QPropertyAssignment> > assignmentsForEnteredStates = | - |
| 1390 | computePropertyAssignments(enteredStates, pendingRestorables); executed (the execution status of this line is deduced): computePropertyAssignments(enteredStates, pendingRestorables); | - |
| 1391 | #ifndef QT_NO_ANIMATION | - |
| 1392 | QList<QAbstractAnimation*> selectedAnimations = selectAnimations(transitions); executed (the execution status of this line is deduced): QList<QAbstractAnimation*> selectedAnimations = selectAnimations(transitions); | - |
| 1393 | #endif | - |
| 1394 | // enterStates() will set stopProcessingReason to Finished if a final | - |
| 1395 | // state is entered. | - |
| 1396 | stopProcessingReason = EventQueueEmpty; executed (the execution status of this line is deduced): stopProcessingReason = EventQueueEmpty; | - |
| 1397 | enterStates(&nullEvent, exitedStates, enteredStates, statesForDefaultEntry, executed (the execution status of this line is deduced): enterStates(&nullEvent, exitedStates, enteredStates, statesForDefaultEntry, | - |
| 1398 | assignmentsForEnteredStates executed (the execution status of this line is deduced): assignmentsForEnteredStates | - |
| 1399 | #ifndef QT_NO_ANIMATION executed (the execution status of this line is deduced): | - |
| 1400 | , selectedAnimations executed (the execution status of this line is deduced): , selectedAnimations | - |
| 1401 | #endif executed (the execution status of this line is deduced): | - |
| 1402 | ); executed (the execution status of this line is deduced): ); | - |
| 1403 | delete initialTransition; executed (the execution status of this line is deduced): delete initialTransition; | - |
| 1404 | | - |
| 1405 | #ifdef QSTATEMACHINE_DEBUG | - |
| 1406 | qDebug() << q << ": initial configuration:" << configuration; | - |
| 1407 | #endif | - |
| 1408 | | - |
| 1409 | emit q->started(QStateMachine::QPrivateSignal()); executed (the execution status of this line is deduced): q->started(QStateMachine::QPrivateSignal()); | - |
| 1410 | | - |
| 1411 | if (stopProcessingReason == Finished) { evaluated: stopProcessingReason == Finished| yes Evaluation Count:2 | yes Evaluation Count:141 |
| 2-141 |
| 1412 | // The state machine immediately reached a final state. | - |
| 1413 | processingScheduled = false; executed (the execution status of this line is deduced): processingScheduled = false; | - |
| 1414 | state = NotRunning; executed (the execution status of this line is deduced): state = NotRunning; | - |
| 1415 | unregisterAllTransitions(); executed (the execution status of this line is deduced): unregisterAllTransitions(); | - |
| 1416 | emitFinished(); executed (the execution status of this line is deduced): emitFinished(); | - |
| 1417 | } else { executed: }Execution Count:2 | 2 |
| 1418 | _q_process(); executed (the execution status of this line is deduced): _q_process(); | - |
| 1419 | } executed: }Execution Count:141 | 141 |
| 1420 | } | - |
| 1421 | | - |
| 1422 | void QStateMachinePrivate::_q_process() | - |
| 1423 | { | - |
| 1424 | Q_Q(QStateMachine); executed (the execution status of this line is deduced): QStateMachine * const q = q_func(); | - |
| 1425 | Q_ASSERT(state == Running); executed (the execution status of this line is deduced): qt_noop(); | - |
| 1426 | Q_ASSERT(!processing); executed (the execution status of this line is deduced): qt_noop(); | - |
| 1427 | processing = true; executed (the execution status of this line is deduced): processing = true; | - |
| 1428 | processingScheduled = false; executed (the execution status of this line is deduced): processingScheduled = false; | - |
| 1429 | #ifdef QSTATEMACHINE_DEBUG | - |
| 1430 | qDebug() << q << ": starting the event processing loop"; | - |
| 1431 | #endif | - |
| 1432 | while (processing) { evaluated: processing| yes Evaluation Count:2518 | yes Evaluation Count:335 |
| 335-2518 |
| 1433 | if (stop) { evaluated: stop| yes Evaluation Count:18 | yes Evaluation Count:2500 |
| 18-2500 |
| 1434 | processing = false; executed (the execution status of this line is deduced): processing = false; | - |
| 1435 | break; executed: break;Execution Count:18 | 18 |
| 1436 | } | - |
| 1437 | QSet<QAbstractTransition*> enabledTransitions; executed (the execution status of this line is deduced): QSet<QAbstractTransition*> enabledTransitions; | - |
| 1438 | QEvent *e = new QEvent(QEvent::None); executed (the execution status of this line is deduced): QEvent *e = new QEvent(QEvent::None); | - |
| 1439 | enabledTransitions = selectTransitions(e); executed (the execution status of this line is deduced): enabledTransitions = selectTransitions(e); | - |
| 1440 | if (enabledTransitions.isEmpty()) { evaluated: enabledTransitions.isEmpty()| yes Evaluation Count:2476 | yes Evaluation Count:24 |
| 24-2476 |
| 1441 | delete e; executed (the execution status of this line is deduced): delete e; | - |
| 1442 | e = 0; executed (the execution status of this line is deduced): e = 0; | - |
| 1443 | } executed: }Execution Count:2476 | 2476 |
| 1444 | if (enabledTransitions.isEmpty() && ((e = dequeueInternalEvent()) != 0)) { evaluated: enabledTransitions.isEmpty()| yes Evaluation Count:2476 | yes Evaluation Count:24 |
evaluated: ((e = dequeueInternalEvent()) != 0)| yes Evaluation Count:88 | yes Evaluation Count:2388 |
| 24-2476 |
| 1445 | #ifdef QSTATEMACHINE_DEBUG | - |
| 1446 | qDebug() << q << ": dequeued internal event" << e << "of type" << e->type(); | - |
| 1447 | #endif | - |
| 1448 | enabledTransitions = selectTransitions(e); executed (the execution status of this line is deduced): enabledTransitions = selectTransitions(e); | - |
| 1449 | if (enabledTransitions.isEmpty()) { evaluated: enabledTransitions.isEmpty()| yes Evaluation Count:7 | yes Evaluation Count:81 |
| 7-81 |
| 1450 | delete e; executed (the execution status of this line is deduced): delete e; | - |
| 1451 | e = 0; executed (the execution status of this line is deduced): e = 0; | - |
| 1452 | } executed: }Execution Count:7 | 7 |
| 1453 | } executed: }Execution Count:88 | 88 |
| 1454 | if (enabledTransitions.isEmpty()) { evaluated: enabledTransitions.isEmpty()| yes Evaluation Count:2395 | yes Evaluation Count:105 |
| 105-2395 |
| 1455 | if ((e = dequeueExternalEvent()) != 0) { evaluated: (e = dequeueExternalEvent()) != 0| yes Evaluation Count:2121 | yes Evaluation Count:274 |
| 274-2121 |
| 1456 | #ifdef QSTATEMACHINE_DEBUG | - |
| 1457 | qDebug() << q << ": dequeued external event" << e << "of type" << e->type(); | - |
| 1458 | #endif | - |
| 1459 | enabledTransitions = selectTransitions(e); executed (the execution status of this line is deduced): enabledTransitions = selectTransitions(e); | - |
| 1460 | if (enabledTransitions.isEmpty()) { evaluated: enabledTransitions.isEmpty()| yes Evaluation Count:1002 | yes Evaluation Count:1119 |
| 1002-1119 |
| 1461 | delete e; executed (the execution status of this line is deduced): delete e; | - |
| 1462 | e = 0; executed (the execution status of this line is deduced): e = 0; | - |
| 1463 | } executed: }Execution Count:1002 | 1002 |
| 1464 | } else { executed: }Execution Count:2121 | 2121 |
| 1465 | if (isInternalEventQueueEmpty()) { partially evaluated: isInternalEventQueueEmpty()| yes Evaluation Count:274 | no Evaluation Count:0 |
| 0-274 |
| 1466 | processing = false; executed (the execution status of this line is deduced): processing = false; | - |
| 1467 | stopProcessingReason = EventQueueEmpty; executed (the execution status of this line is deduced): stopProcessingReason = EventQueueEmpty; | - |
| 1468 | } executed: }Execution Count:274 | 274 |
| 1469 | } executed: }Execution Count:274 | 274 |
| 1470 | } | - |
| 1471 | if (!enabledTransitions.isEmpty()) { evaluated: !enabledTransitions.isEmpty()| yes Evaluation Count:1224 | yes Evaluation Count:1276 |
| 1224-1276 |
| 1472 | q->beginMicrostep(e); executed (the execution status of this line is deduced): q->beginMicrostep(e); | - |
| 1473 | microstep(e, enabledTransitions.toList()); executed (the execution status of this line is deduced): microstep(e, enabledTransitions.toList()); | - |
| 1474 | q->endMicrostep(e); executed (the execution status of this line is deduced): q->endMicrostep(e); | - |
| 1475 | } executed: }Execution Count:1224 | 1224 |
| 1476 | #ifdef QSTATEMACHINE_DEBUG | - |
| 1477 | else { | - |
| 1478 | qDebug() << q << ": no transitions enabled"; | - |
| 1479 | } | - |
| 1480 | #endif | - |
| 1481 | delete e; executed (the execution status of this line is deduced): delete e; | - |
| 1482 | } executed: }Execution Count:2500 | 2500 |
| 1483 | #ifdef QSTATEMACHINE_DEBUG | - |
| 1484 | qDebug() << q << ": finished the event processing loop"; | - |
| 1485 | #endif | - |
| 1486 | if (stop) { evaluated: stop| yes Evaluation Count:20 | yes Evaluation Count:333 |
| 20-333 |
| 1487 | stop = false; executed (the execution status of this line is deduced): stop = false; | - |
| 1488 | stopProcessingReason = Stopped; executed (the execution status of this line is deduced): stopProcessingReason = Stopped; | - |
| 1489 | } executed: }Execution Count:20 | 20 |
| 1490 | | - |
| 1491 | switch (stopProcessingReason) { | - |
| 1492 | case EventQueueEmpty: | - |
| 1493 | break; executed: break;Execution Count:273 | 273 |
| 1494 | case Finished: | - |
| 1495 | state = NotRunning; executed (the execution status of this line is deduced): state = NotRunning; | - |
| 1496 | cancelAllDelayedEvents(); executed (the execution status of this line is deduced): cancelAllDelayedEvents(); | - |
| 1497 | unregisterAllTransitions(); executed (the execution status of this line is deduced): unregisterAllTransitions(); | - |
| 1498 | emitFinished(); executed (the execution status of this line is deduced): emitFinished(); | - |
| 1499 | break; executed: break;Execution Count:60 | 60 |
| 1500 | case Stopped: | - |
| 1501 | state = NotRunning; executed (the execution status of this line is deduced): state = NotRunning; | - |
| 1502 | cancelAllDelayedEvents(); executed (the execution status of this line is deduced): cancelAllDelayedEvents(); | - |
| 1503 | unregisterAllTransitions(); executed (the execution status of this line is deduced): unregisterAllTransitions(); | - |
| 1504 | emit q->stopped(QStateMachine::QPrivateSignal()); executed (the execution status of this line is deduced): q->stopped(QStateMachine::QPrivateSignal()); | - |
| 1505 | break; executed: break;Execution Count:20 | 20 |
| 1506 | } | - |
| 1507 | } executed: }Execution Count:353 | 353 |
| 1508 | | - |
| 1509 | void QStateMachinePrivate::_q_startDelayedEventTimer(int id, int delay) | - |
| 1510 | { | - |
| 1511 | Q_Q(QStateMachine); executed (the execution status of this line is deduced): QStateMachine * const q = q_func(); | - |
| 1512 | QMutexLocker locker(&delayedEventsMutex); executed (the execution status of this line is deduced): QMutexLocker locker(&delayedEventsMutex); | - |
| 1513 | QHash<int, DelayedEvent>::iterator it = delayedEvents.find(id); executed (the execution status of this line is deduced): QHash<int, DelayedEvent>::iterator it = delayedEvents.find(id); | - |
| 1514 | if (it != delayedEvents.end()) { evaluated: it != delayedEvents.end()| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
| 1515 | DelayedEvent &e = it.value(); executed (the execution status of this line is deduced): DelayedEvent &e = it.value(); | - |
| 1516 | Q_ASSERT(!e.timerId); executed (the execution status of this line is deduced): qt_noop(); | - |
| 1517 | e.timerId = q->startTimer(delay); executed (the execution status of this line is deduced): e.timerId = q->startTimer(delay); | - |
| 1518 | if (!e.timerId) { partially evaluated: !e.timerId| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 1519 | qWarning("QStateMachine::postDelayedEvent: failed to start timer (id=%d, delay=%d)", id, delay); never executed (the execution status of this line is deduced): QMessageLogger("statemachine/qstatemachine.cpp", 1519, __PRETTY_FUNCTION__).warning("QStateMachine::postDelayedEvent: failed to start timer (id=%d, delay=%d)", id, delay); | - |
| 1520 | delayedEvents.erase(it); never executed (the execution status of this line is deduced): delayedEvents.erase(it); | - |
| 1521 | delayedEventIdFreeList.release(id); never executed (the execution status of this line is deduced): delayedEventIdFreeList.release(id); | - |
| 1522 | } else { | 0 |
| 1523 | timerIdToDelayedEventId.insert(e.timerId, id); executed (the execution status of this line is deduced): timerIdToDelayedEventId.insert(e.timerId, id); | - |
| 1524 | } executed: }Execution Count:1 | 1 |
| 1525 | } else { | - |
| 1526 | // It's been cancelled already | - |
| 1527 | delayedEventIdFreeList.release(id); executed (the execution status of this line is deduced): delayedEventIdFreeList.release(id); | - |
| 1528 | } executed: }Execution Count:1 | 1 |
| 1529 | } | - |
| 1530 | | - |
| 1531 | void QStateMachinePrivate::_q_killDelayedEventTimer(int id, int timerId) | - |
| 1532 | { | - |
| 1533 | Q_Q(QStateMachine); never executed (the execution status of this line is deduced): QStateMachine * const q = q_func(); | - |
| 1534 | q->killTimer(timerId); never executed (the execution status of this line is deduced): q->killTimer(timerId); | - |
| 1535 | QMutexLocker locker(&delayedEventsMutex); never executed (the execution status of this line is deduced): QMutexLocker locker(&delayedEventsMutex); | - |
| 1536 | delayedEventIdFreeList.release(id); never executed (the execution status of this line is deduced): delayedEventIdFreeList.release(id); | - |
| 1537 | } | 0 |
| 1538 | | - |
| 1539 | void QStateMachinePrivate::postInternalEvent(QEvent *e) | - |
| 1540 | { | - |
| 1541 | QMutexLocker locker(&internalEventMutex); executed (the execution status of this line is deduced): QMutexLocker locker(&internalEventMutex); | - |
| 1542 | internalEventQueue.append(e); executed (the execution status of this line is deduced): internalEventQueue.append(e); | - |
| 1543 | } executed: }Execution Count:88 | 88 |
| 1544 | | - |
| 1545 | void QStateMachinePrivate::postExternalEvent(QEvent *e) | - |
| 1546 | { | - |
| 1547 | QMutexLocker locker(&externalEventMutex); executed (the execution status of this line is deduced): QMutexLocker locker(&externalEventMutex); | - |
| 1548 | externalEventQueue.append(e); executed (the execution status of this line is deduced): externalEventQueue.append(e); | - |
| 1549 | } executed: }Execution Count:2122 | 2122 |
| 1550 | | - |
| 1551 | QEvent *QStateMachinePrivate::dequeueInternalEvent() | - |
| 1552 | { | - |
| 1553 | QMutexLocker locker(&internalEventMutex); executed (the execution status of this line is deduced): QMutexLocker locker(&internalEventMutex); | - |
| 1554 | if (internalEventQueue.isEmpty()) evaluated: internalEventQueue.isEmpty()| yes Evaluation Count:2388 | yes Evaluation Count:88 |
| 88-2388 |
| 1555 | return 0; executed: return 0;Execution Count:2388 | 2388 |
| 1556 | return internalEventQueue.takeFirst(); executed: return internalEventQueue.takeFirst();Execution Count:88 | 88 |
| 1557 | } | - |
| 1558 | | - |
| 1559 | QEvent *QStateMachinePrivate::dequeueExternalEvent() | - |
| 1560 | { | - |
| 1561 | QMutexLocker locker(&externalEventMutex); executed (the execution status of this line is deduced): QMutexLocker locker(&externalEventMutex); | - |
| 1562 | if (externalEventQueue.isEmpty()) evaluated: externalEventQueue.isEmpty()| yes Evaluation Count:274 | yes Evaluation Count:2121 |
| 274-2121 |
| 1563 | return 0; executed: return 0;Execution Count:274 | 274 |
| 1564 | return externalEventQueue.takeFirst(); executed: return externalEventQueue.takeFirst();Execution Count:2121 | 2121 |
| 1565 | } | - |
| 1566 | | - |
| 1567 | bool QStateMachinePrivate::isInternalEventQueueEmpty() | - |
| 1568 | { | - |
| 1569 | QMutexLocker locker(&internalEventMutex); executed (the execution status of this line is deduced): QMutexLocker locker(&internalEventMutex); | - |
| 1570 | return internalEventQueue.isEmpty(); executed: return internalEventQueue.isEmpty();Execution Count:274 | 274 |
| 1571 | } | - |
| 1572 | | - |
| 1573 | bool QStateMachinePrivate::isExternalEventQueueEmpty() | - |
| 1574 | { | - |
| 1575 | QMutexLocker locker(&externalEventMutex); never executed (the execution status of this line is deduced): QMutexLocker locker(&externalEventMutex); | - |
| 1576 | return externalEventQueue.isEmpty(); never executed: return externalEventQueue.isEmpty(); | 0 |
| 1577 | } | - |
| 1578 | | - |
| 1579 | void QStateMachinePrivate::processEvents(EventProcessingMode processingMode) | - |
| 1580 | { | - |
| 1581 | Q_Q(QStateMachine); executed (the execution status of this line is deduced): QStateMachine * const q = q_func(); | - |
| 1582 | if ((state != Running) || processing || processingScheduled) partially evaluated: (state != Running)| no Evaluation Count:0 | yes Evaluation Count:2234 |
evaluated: processing| yes Evaluation Count:1013 | yes Evaluation Count:1221 |
evaluated: processingScheduled| yes Evaluation Count:1009 | yes Evaluation Count:212 |
| 0-2234 |
| 1583 | return; executed: return;Execution Count:2022 | 2022 |
| 1584 | switch (processingMode) { | - |
| 1585 | case DirectProcessing: | - |
| 1586 | if (QThread::currentThread() == q->thread()) { partially evaluated: QThread::currentThread() == q->thread()| yes Evaluation Count:86 | no Evaluation Count:0 |
| 0-86 |
| 1587 | _q_process(); executed (the execution status of this line is deduced): _q_process(); | - |
| 1588 | break; executed: break;Execution Count:86 | 86 |
| 1589 | } // fallthrough -- processing must be done in the machine thread | - |
| 1590 | case QueuedProcessing: code before this statement never executed: case QueuedProcessing: | 0 |
| 1591 | processingScheduled = true; executed (the execution status of this line is deduced): processingScheduled = true; | - |
| 1592 | QMetaObject::invokeMethod(q, "_q_process", Qt::QueuedConnection); executed (the execution status of this line is deduced): QMetaObject::invokeMethod(q, "_q_process", Qt::QueuedConnection); | - |
| 1593 | break; executed: break;Execution Count:126 | 126 |
| 1594 | } | - |
| 1595 | } executed: }Execution Count:212 | 212 |
| 1596 | | - |
| 1597 | void QStateMachinePrivate::cancelAllDelayedEvents() | - |
| 1598 | { | - |
| 1599 | Q_Q(QStateMachine); executed (the execution status of this line is deduced): QStateMachine * const q = q_func(); | - |
| 1600 | QMutexLocker locker(&delayedEventsMutex); executed (the execution status of this line is deduced): QMutexLocker locker(&delayedEventsMutex); | - |
| 1601 | QHash<int, DelayedEvent>::const_iterator it; executed (the execution status of this line is deduced): QHash<int, DelayedEvent>::const_iterator it; | - |
| 1602 | for (it = delayedEvents.constBegin(); it != delayedEvents.constEnd(); ++it) { evaluated: it != delayedEvents.constEnd()| yes Evaluation Count:2 | yes Evaluation Count:80 |
| 2-80 |
| 1603 | const DelayedEvent &e = it.value(); executed (the execution status of this line is deduced): const DelayedEvent &e = it.value(); | - |
| 1604 | if (e.timerId) { partially evaluated: e.timerId| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
| 1605 | timerIdToDelayedEventId.remove(e.timerId); executed (the execution status of this line is deduced): timerIdToDelayedEventId.remove(e.timerId); | - |
| 1606 | q->killTimer(e.timerId); executed (the execution status of this line is deduced): q->killTimer(e.timerId); | - |
| 1607 | delayedEventIdFreeList.release(it.key()); executed (the execution status of this line is deduced): delayedEventIdFreeList.release(it.key()); | - |
| 1608 | } else { executed: }Execution Count:2 | 2 |
| 1609 | // Cancellation will be detected in pending _q_startDelayedEventTimer() call | - |
| 1610 | } | 0 |
| 1611 | delete e.event; executed (the execution status of this line is deduced): delete e.event; | - |
| 1612 | } executed: }Execution Count:2 | 2 |
| 1613 | delayedEvents.clear(); executed (the execution status of this line is deduced): delayedEvents.clear(); | - |
| 1614 | } executed: }Execution Count:80 | 80 |
| 1615 | | - |
| 1616 | namespace _QStateMachine_Internal{ | - |
| 1617 | | - |
| 1618 | class GoToStateTransition : public QAbstractTransition | - |
| 1619 | { | - |
| 1620 | Q_OBJECT | - |
| 1621 | public: | - |
| 1622 | GoToStateTransition(QAbstractState *target) | - |
| 1623 | : QAbstractTransition() | - |
| 1624 | { setTargetState(target); } executed: }Execution Count:4 | 4 |
| 1625 | protected: | - |
| 1626 | void onTransition(QEvent *) { deleteLater(); } executed: }Execution Count:4 | 4 |
| 1627 | bool eventTest(QEvent *) { return true; } executed: return true;Execution Count:4 | 4 |
| 1628 | }; | - |
| 1629 | | - |
| 1630 | } // namespace | - |
| 1631 | // mingw compiler tries to export QObject::findChild<GoToStateTransition>(), | - |
| 1632 | // which doesn't work if its in an anonymous namespace. | - |
| 1633 | using namespace _QStateMachine_Internal; | - |
| 1634 | /*! | - |
| 1635 | \internal | - |
| 1636 | | - |
| 1637 | Causes this state machine to unconditionally transition to the given | - |
| 1638 | \a targetState. | - |
| 1639 | | - |
| 1640 | Provides a backdoor for using the state machine "imperatively"; i.e. rather | - |
| 1641 | than defining explicit transitions, you drive the machine's execution by | - |
| 1642 | calling this function. It breaks the whole integrity of the | - |
| 1643 | transition-driven model, but is provided for pragmatic reasons. | - |
| 1644 | */ | - |
| 1645 | void QStateMachinePrivate::goToState(QAbstractState *targetState) | - |
| 1646 | { | - |
| 1647 | if (!targetState) { partially evaluated: !targetState| no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
| 1648 | qWarning("QStateMachine::goToState(): cannot go to null state"); never executed (the execution status of this line is deduced): QMessageLogger("statemachine/qstatemachine.cpp", 1648, __PRETTY_FUNCTION__).warning("QStateMachine::goToState(): cannot go to null state"); | - |
| 1649 | return; | 0 |
| 1650 | } | - |
| 1651 | | - |
| 1652 | if (configuration.contains(targetState)) evaluated: configuration.contains(targetState)| yes Evaluation Count:2 | yes Evaluation Count:5 |
| 2-5 |
| 1653 | return; executed: return;Execution Count:2 | 2 |
| 1654 | | - |
| 1655 | Q_ASSERT(state == Running); executed (the execution status of this line is deduced): qt_noop(); | - |
| 1656 | QState *sourceState = 0; executed (the execution status of this line is deduced): QState *sourceState = 0; | - |
| 1657 | QSet<QAbstractState*>::const_iterator it; executed (the execution status of this line is deduced): QSet<QAbstractState*>::const_iterator it; | - |
| 1658 | for (it = configuration.constBegin(); it != configuration.constEnd(); ++it) { partially evaluated: it != configuration.constEnd()| yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
| 1659 | sourceState = toStandardState(*it); executed (the execution status of this line is deduced): sourceState = toStandardState(*it); | - |
| 1660 | if (sourceState != 0) partially evaluated: sourceState != 0| yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
| 1661 | break; executed: break;Execution Count:5 | 5 |
| 1662 | } | 0 |
| 1663 | | - |
| 1664 | Q_ASSERT(sourceState != 0); executed (the execution status of this line is deduced): qt_noop(); | - |
| 1665 | // Reuse previous GoToStateTransition in case of several calls to | - |
| 1666 | // goToState() in a row. | - |
| 1667 | GoToStateTransition *trans = sourceState->findChild<GoToStateTransition*>(); executed (the execution status of this line is deduced): GoToStateTransition *trans = sourceState->findChild<GoToStateTransition*>(); | - |
| 1668 | if (!trans) { evaluated: !trans| yes Evaluation Count:4 | yes Evaluation Count:1 |
| 1-4 |
| 1669 | trans = new GoToStateTransition(targetState); executed (the execution status of this line is deduced): trans = new GoToStateTransition(targetState); | - |
| 1670 | sourceState->addTransition(trans); executed (the execution status of this line is deduced): sourceState->addTransition(trans); | - |
| 1671 | } else { executed: }Execution Count:4 | 4 |
| 1672 | trans->setTargetState(targetState); executed (the execution status of this line is deduced): trans->setTargetState(targetState); | - |
| 1673 | } executed: }Execution Count:1 | 1 |
| 1674 | | - |
| 1675 | processEvents(QueuedProcessing); executed (the execution status of this line is deduced): processEvents(QueuedProcessing); | - |
| 1676 | } executed: }Execution Count:5 | 5 |
| 1677 | | - |
| 1678 | void QStateMachinePrivate::registerTransitions(QAbstractState *state) | - |
| 1679 | { | - |
| 1680 | QState *group = toStandardState(state); executed (the execution status of this line is deduced): QState *group = toStandardState(state); | - |
| 1681 | if (!group) evaluated: !group| yes Evaluation Count:70 | yes Evaluation Count:1372 |
| 70-1372 |
| 1682 | return; executed: return;Execution Count:70 | 70 |
| 1683 | QList<QAbstractTransition*> transitions = QStatePrivate::get(group)->transitions(); executed (the execution status of this line is deduced): QList<QAbstractTransition*> transitions = QStatePrivate::get(group)->transitions(); | - |
| 1684 | for (int i = 0; i < transitions.size(); ++i) { evaluated: i < transitions.size()| yes Evaluation Count:2293 | yes Evaluation Count:1372 |
| 1372-2293 |
| 1685 | QAbstractTransition *t = transitions.at(i); executed (the execution status of this line is deduced): QAbstractTransition *t = transitions.at(i); | - |
| 1686 | registerTransition(t); executed (the execution status of this line is deduced): registerTransition(t); | - |
| 1687 | } executed: }Execution Count:2293 | 2293 |
| 1688 | } executed: }Execution Count:1372 | 1372 |
| 1689 | | - |
| 1690 | void QStateMachinePrivate::maybeRegisterTransition(QAbstractTransition *transition) | - |
| 1691 | { | - |
| 1692 | if (QSignalTransition *st = qobject_cast<QSignalTransition*>(transition)) { evaluated: QSignalTransition *st = qobject_cast<QSignalTransition*>(transition)| yes Evaluation Count:57 | yes Evaluation Count:150 |
| 57-150 |
| 1693 | maybeRegisterSignalTransition(st); executed (the execution status of this line is deduced): maybeRegisterSignalTransition(st); | - |
| 1694 | } executed: }Execution Count:57 | 57 |
| 1695 | #ifndef QT_NO_STATEMACHINE_EVENTFILTER | - |
| 1696 | else if (QEventTransition *et = qobject_cast<QEventTransition*>(transition)) { evaluated: QEventTransition *et = qobject_cast<QEventTransition*>(transition)| yes Evaluation Count:16 | yes Evaluation Count:134 |
| 16-134 |
| 1697 | maybeRegisterEventTransition(et); executed (the execution status of this line is deduced): maybeRegisterEventTransition(et); | - |
| 1698 | } executed: }Execution Count:16 | 16 |
| 1699 | #endif | - |
| 1700 | } | - |
| 1701 | | - |
| 1702 | void QStateMachinePrivate::registerTransition(QAbstractTransition *transition) | - |
| 1703 | { | - |
| 1704 | if (QSignalTransition *st = qobject_cast<QSignalTransition*>(transition)) { evaluated: QSignalTransition *st = qobject_cast<QSignalTransition*>(transition)| yes Evaluation Count:1066 | yes Evaluation Count:1227 |
| 1066-1227 |
| 1705 | registerSignalTransition(st); executed (the execution status of this line is deduced): registerSignalTransition(st); | - |
| 1706 | } executed: }Execution Count:1066 | 1066 |
| 1707 | #ifndef QT_NO_STATEMACHINE_EVENTFILTER | - |
| 1708 | else if (QEventTransition *oet = qobject_cast<QEventTransition*>(transition)) { evaluated: QEventTransition *oet = qobject_cast<QEventTransition*>(transition)| yes Evaluation Count:20 | yes Evaluation Count:1207 |
| 20-1207 |
| 1709 | registerEventTransition(oet); executed (the execution status of this line is deduced): registerEventTransition(oet); | - |
| 1710 | } executed: }Execution Count:20 | 20 |
| 1711 | #endif | - |
| 1712 | } | - |
| 1713 | | - |
| 1714 | void QStateMachinePrivate::unregisterTransition(QAbstractTransition *transition) | - |
| 1715 | { | - |
| 1716 | if (QSignalTransition *st = qobject_cast<QSignalTransition*>(transition)) { evaluated: QSignalTransition *st = qobject_cast<QSignalTransition*>(transition)| yes Evaluation Count:2 | yes Evaluation Count:3 |
| 2-3 |
| 1717 | unregisterSignalTransition(st); executed (the execution status of this line is deduced): unregisterSignalTransition(st); | - |
| 1718 | } executed: }Execution Count:2 | 2 |
| 1719 | #ifndef QT_NO_STATEMACHINE_EVENTFILTER | - |
| 1720 | else if (QEventTransition *oet = qobject_cast<QEventTransition*>(transition)) { evaluated: QEventTransition *oet = qobject_cast<QEventTransition*>(transition)| yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
| 1721 | unregisterEventTransition(oet); executed (the execution status of this line is deduced): unregisterEventTransition(oet); | - |
| 1722 | } executed: }Execution Count:2 | 2 |
| 1723 | #endif | - |
| 1724 | } | - |
| 1725 | | - |
| 1726 | void QStateMachinePrivate::maybeRegisterSignalTransition(QSignalTransition *transition) | - |
| 1727 | { | - |
| 1728 | Q_Q(QStateMachine); executed (the execution status of this line is deduced): QStateMachine * const q = q_func(); | - |
| 1729 | if ((state == Running) && (configuration.contains(transition->sourceState()) evaluated: (state == Running)| yes Evaluation Count:200011 | yes Evaluation Count:55 |
evaluated: configuration.contains(transition->sourceState())| yes Evaluation Count:200009 | yes Evaluation Count:1 |
| 1-200011 |
| 1730 | || (transition->senderObject() && (transition->senderObject()->thread() != q->thread())))) { partially evaluated: transition->senderObject()| yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: (transition->senderObject()->thread() != q->thread())| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 1731 | registerSignalTransition(transition); executed (the execution status of this line is deduced): registerSignalTransition(transition); | - |
| 1732 | } executed: }Execution Count:200011 | 200011 |
| 1733 | } executed: }Execution Count:200067 | 200067 |
| 1734 | | - |
| 1735 | void QStateMachinePrivate::registerSignalTransition(QSignalTransition *transition) | - |
| 1736 | { | - |
| 1737 | Q_Q(QStateMachine); executed (the execution status of this line is deduced): QStateMachine * const q = q_func(); | - |
| 1738 | if (QSignalTransitionPrivate::get(transition)->signalIndex != -1) evaluated: QSignalTransitionPrivate::get(transition)->signalIndex != -1| yes Evaluation Count:1007 | yes Evaluation Count:200076 |
| 1007-200076 |
| 1739 | return; // already registered executed: return;Execution Count:1007 | 1007 |
| 1740 | const QObject *sender = QSignalTransitionPrivate::get(transition)->sender; executed (the execution status of this line is deduced): const QObject *sender = QSignalTransitionPrivate::get(transition)->sender; | - |
| 1741 | if (!sender) evaluated: !sender| yes Evaluation Count:100003 | yes Evaluation Count:100074 |
| 100003-100074 |
| 1742 | return; executed: return;Execution Count:100003 | 100003 |
| 1743 | QByteArray signal = QSignalTransitionPrivate::get(transition)->signal; executed (the execution status of this line is deduced): QByteArray signal = QSignalTransitionPrivate::get(transition)->signal; | - |
| 1744 | if (signal.isEmpty()) evaluated: signal.isEmpty()| yes Evaluation Count:1 | yes Evaluation Count:100073 |
| 1-100073 |
| 1745 | return; executed: return;Execution Count:1 | 1 |
| 1746 | if (signal.startsWith('0'+QSIGNAL_CODE)) evaluated: signal.startsWith('0'+2)| yes Evaluation Count:100071 | yes Evaluation Count:2 |
| 2-100071 |
| 1747 | signal.remove(0, 1); executed: signal.remove(0, 1);Execution Count:100071 | 100071 |
| 1748 | const QMetaObject *meta = sender->metaObject(); executed (the execution status of this line is deduced): const QMetaObject *meta = sender->metaObject(); | - |
| 1749 | int signalIndex = meta->indexOfSignal(signal); executed (the execution status of this line is deduced): int signalIndex = meta->indexOfSignal(signal); | - |
| 1750 | int originalSignalIndex = signalIndex; executed (the execution status of this line is deduced): int originalSignalIndex = signalIndex; | - |
| 1751 | if (signalIndex == -1) { evaluated: signalIndex == -1| yes Evaluation Count:1 | yes Evaluation Count:100072 |
| 1-100072 |
| 1752 | signalIndex = meta->indexOfSignal(QMetaObject::normalizedSignature(signal)); executed (the execution status of this line is deduced): signalIndex = meta->indexOfSignal(QMetaObject::normalizedSignature(signal)); | - |
| 1753 | if (signalIndex == -1) { partially evaluated: signalIndex == -1| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 1754 | qWarning("QSignalTransition: no such signal: %s::%s", executed (the execution status of this line is deduced): QMessageLogger("statemachine/qstatemachine.cpp", 1754, __PRETTY_FUNCTION__).warning("QSignalTransition: no such signal: %s::%s", | - |
| 1755 | meta->className(), signal.constData()); executed (the execution status of this line is deduced): meta->className(), signal.constData()); | - |
| 1756 | return; executed: return;Execution Count:1 | 1 |
| 1757 | } | - |
| 1758 | originalSignalIndex = signalIndex; never executed (the execution status of this line is deduced): originalSignalIndex = signalIndex; | - |
| 1759 | } | 0 |
| 1760 | // The signal index we actually want to connect to is the one | - |
| 1761 | // that is going to be sent, i.e. the non-cloned original index. | - |
| 1762 | while (meta->method(signalIndex).attributes() & QMetaMethod::Cloned) evaluated: meta->method(signalIndex).attributes() & QMetaMethod::Cloned| yes Evaluation Count:2 | yes Evaluation Count:100070 |
| 2-100070 |
| 1763 | --signalIndex; executed: --signalIndex;Execution Count:2 | 2 |
| 1764 | | - |
| 1765 | connectionsMutex.lock(); executed (the execution status of this line is deduced): connectionsMutex.lock(); | - |
| 1766 | QVector<int> &connectedSignalIndexes = connections[sender]; executed (the execution status of this line is deduced): QVector<int> &connectedSignalIndexes = connections[sender]; | - |
| 1767 | if (connectedSignalIndexes.size() <= signalIndex) evaluated: connectedSignalIndexes.size() <= signalIndex| yes Evaluation Count:100065 | yes Evaluation Count:7 |
| 7-100065 |
| 1768 | connectedSignalIndexes.resize(signalIndex+1); executed: connectedSignalIndexes.resize(signalIndex+1);Execution Count:100065 | 100065 |
| 1769 | if (connectedSignalIndexes.at(signalIndex) == 0) { evaluated: connectedSignalIndexes.at(signalIndex) == 0| yes Evaluation Count:100065 | yes Evaluation Count:7 |
| 7-100065 |
| 1770 | if (!signalEventGenerator) evaluated: !signalEventGenerator| yes Evaluation Count:37 | yes Evaluation Count:100028 |
| 37-100028 |
| 1771 | signalEventGenerator = new QSignalEventGenerator(q); executed: signalEventGenerator = new QSignalEventGenerator(q);Execution Count:37 | 37 |
| 1772 | static const int generatorMethodOffset = QSignalEventGenerator::staticMetaObject.methodOffset(); | - |
| 1773 | bool ok = QMetaObject::connect(sender, signalIndex, signalEventGenerator, generatorMethodOffset); executed (the execution status of this line is deduced): bool ok = QMetaObject::connect(sender, signalIndex, signalEventGenerator, generatorMethodOffset); | - |
| 1774 | if (!ok) { partially evaluated: !ok| no Evaluation Count:0 | yes Evaluation Count:100065 |
| 0-100065 |
| 1775 | #ifdef QSTATEMACHINE_DEBUG | - |
| 1776 | qDebug() << q << ": FAILED to add signal transition from" << transition->sourceState() | - |
| 1777 | << ": ( sender =" << sender << ", signal =" << signal | - |
| 1778 | << ", targets =" << transition->targetStates() << ')'; | - |
| 1779 | #endif | - |
| 1780 | return; | 0 |
| 1781 | } | - |
| 1782 | } executed: }Execution Count:100065 | 100065 |
| 1783 | ++connectedSignalIndexes[signalIndex]; executed (the execution status of this line is deduced): ++connectedSignalIndexes[signalIndex]; | - |
| 1784 | connectionsMutex.unlock(); executed (the execution status of this line is deduced): connectionsMutex.unlock(); | - |
| 1785 | | - |
| 1786 | QSignalTransitionPrivate::get(transition)->signalIndex = signalIndex; executed (the execution status of this line is deduced): QSignalTransitionPrivate::get(transition)->signalIndex = signalIndex; | - |
| 1787 | QSignalTransitionPrivate::get(transition)->originalSignalIndex = originalSignalIndex; executed (the execution status of this line is deduced): QSignalTransitionPrivate::get(transition)->originalSignalIndex = originalSignalIndex; | - |
| 1788 | #ifdef QSTATEMACHINE_DEBUG | - |
| 1789 | qDebug() << q << ": added signal transition from" << transition->sourceState() | - |
| 1790 | << ": ( sender =" << sender << ", signal =" << signal | - |
| 1791 | << ", targets =" << transition->targetStates() << ')'; | - |
| 1792 | #endif | - |
| 1793 | } executed: }Execution Count:100070 | 100070 |
| 1794 | | - |
| 1795 | void QStateMachinePrivate::unregisterSignalTransition(QSignalTransition *transition) | - |
| 1796 | { | - |
| 1797 | int signalIndex = QSignalTransitionPrivate::get(transition)->signalIndex; executed (the execution status of this line is deduced): int signalIndex = QSignalTransitionPrivate::get(transition)->signalIndex; | - |
| 1798 | if (signalIndex == -1) partially evaluated: signalIndex == -1| no Evaluation Count:0 | yes Evaluation Count:100042 |
| 0-100042 |
| 1799 | return; // not registered | 0 |
| 1800 | const QObject *sender = QSignalTransitionPrivate::get(transition)->sender; executed (the execution status of this line is deduced): const QObject *sender = QSignalTransitionPrivate::get(transition)->sender; | - |
| 1801 | QSignalTransitionPrivate::get(transition)->signalIndex = -1; executed (the execution status of this line is deduced): QSignalTransitionPrivate::get(transition)->signalIndex = -1; | - |
| 1802 | | - |
| 1803 | connectionsMutex.lock(); executed (the execution status of this line is deduced): connectionsMutex.lock(); | - |
| 1804 | QVector<int> &connectedSignalIndexes = connections[sender]; executed (the execution status of this line is deduced): QVector<int> &connectedSignalIndexes = connections[sender]; | - |
| 1805 | Q_ASSERT(connectedSignalIndexes.size() > signalIndex); executed (the execution status of this line is deduced): qt_noop(); | - |
| 1806 | Q_ASSERT(connectedSignalIndexes.at(signalIndex) != 0); executed (the execution status of this line is deduced): qt_noop(); | - |
| 1807 | if (--connectedSignalIndexes[signalIndex] == 0) { evaluated: --connectedSignalIndexes[signalIndex] == 0| yes Evaluation Count:100047 | yes Evaluation Count:1 |
| 1-100047 |
| 1808 | Q_ASSERT(signalEventGenerator != 0); executed (the execution status of this line is deduced): qt_noop(); | - |
| 1809 | static const int generatorMethodOffset = QSignalEventGenerator::staticMetaObject.methodOffset(); | - |
| 1810 | QMetaObject::disconnect(sender, signalIndex, signalEventGenerator, generatorMethodOffset); executed (the execution status of this line is deduced): QMetaObject::disconnect(sender, signalIndex, signalEventGenerator, generatorMethodOffset); | - |
| 1811 | int sum = 0; executed (the execution status of this line is deduced): int sum = 0; | - |
| 1812 | for (int i = 0; i < connectedSignalIndexes.size(); ++i) evaluated: i < connectedSignalIndexes.size()| yes Evaluation Count:300385 | yes Evaluation Count:100047 |
| 100047-300385 |
| 1813 | sum += connectedSignalIndexes.at(i); executed: sum += connectedSignalIndexes.at(i);Execution Count:300385 | 300385 |
| 1814 | if (sum == 0) evaluated: sum == 0| yes Evaluation Count:100037 | yes Evaluation Count:10 |
| 10-100037 |
| 1815 | connections.remove(sender); executed: connections.remove(sender);Execution Count:100037 | 100037 |
| 1816 | } executed: }Execution Count:100047 | 100047 |
| 1817 | connectionsMutex.unlock(); executed (the execution status of this line is deduced): connectionsMutex.unlock(); | - |
| 1818 | } executed: }Execution Count:100047 | 100047 |
| 1819 | | - |
| 1820 | void QStateMachinePrivate::unregisterAllTransitions() | - |
| 1821 | { | - |
| 1822 | Q_Q(QStateMachine); executed (the execution status of this line is deduced): QStateMachine * const q = q_func(); | - |
| 1823 | { | - |
| 1824 | QList<QSignalTransition*> transitions = rootState()->findChildren<QSignalTransition*>(); executed (the execution status of this line is deduced): QList<QSignalTransition*> transitions = rootState()->findChildren<QSignalTransition*>(); | - |
| 1825 | for (int i = 0; i < transitions.size(); ++i) { evaluated: i < transitions.size()| yes Evaluation Count:46 | yes Evaluation Count:82 |
| 46-82 |
| 1826 | QSignalTransition *t = transitions.at(i); executed (the execution status of this line is deduced): QSignalTransition *t = transitions.at(i); | - |
| 1827 | if (t->machine() == q) evaluated: t->machine() == q| yes Evaluation Count:43 | yes Evaluation Count:3 |
| 3-43 |
| 1828 | unregisterSignalTransition(t); executed: unregisterSignalTransition(t);Execution Count:43 | 43 |
| 1829 | } executed: }Execution Count:46 | 46 |
| 1830 | } | - |
| 1831 | { | - |
| 1832 | QList<QEventTransition*> transitions = rootState()->findChildren<QEventTransition*>(); executed (the execution status of this line is deduced): QList<QEventTransition*> transitions = rootState()->findChildren<QEventTransition*>(); | - |
| 1833 | for (int i = 0; i < transitions.size(); ++i) { evaluated: i < transitions.size()| yes Evaluation Count:15 | yes Evaluation Count:82 |
| 15-82 |
| 1834 | QEventTransition *t = transitions.at(i); executed (the execution status of this line is deduced): QEventTransition *t = transitions.at(i); | - |
| 1835 | if (t->machine() == q) partially evaluated: t->machine() == q| yes Evaluation Count:15 | no Evaluation Count:0 |
| 0-15 |
| 1836 | unregisterEventTransition(t); executed: unregisterEventTransition(t);Execution Count:15 | 15 |
| 1837 | } executed: }Execution Count:15 | 15 |
| 1838 | } | - |
| 1839 | } executed: }Execution Count:82 | 82 |
| 1840 | | - |
| 1841 | #ifndef QT_NO_STATEMACHINE_EVENTFILTER | - |
| 1842 | void QStateMachinePrivate::maybeRegisterEventTransition(QEventTransition *transition) | - |
| 1843 | { | - |
| 1844 | if ((state == Running) && configuration.contains(transition->sourceState())) evaluated: (state == Running)| yes Evaluation Count:8 | yes Evaluation Count:15 |
evaluated: configuration.contains(transition->sourceState())| yes Evaluation Count:7 | yes Evaluation Count:1 |
| 1-15 |
| 1845 | registerEventTransition(transition); executed: registerEventTransition(transition);Execution Count:7 | 7 |
| 1846 | } executed: }Execution Count:23 | 23 |
| 1847 | | - |
| 1848 | void QStateMachinePrivate::registerEventTransition(QEventTransition *transition) | - |
| 1849 | { | - |
| 1850 | Q_Q(QStateMachine); executed (the execution status of this line is deduced): QStateMachine * const q = q_func(); | - |
| 1851 | if (QEventTransitionPrivate::get(transition)->registered) partially evaluated: QEventTransitionPrivate::get(transition)->registered| no Evaluation Count:0 | yes Evaluation Count:27 |
| 0-27 |
| 1852 | return; | 0 |
| 1853 | if (transition->eventType() >= QEvent::User) { evaluated: transition->eventType() >= QEvent::User| yes Evaluation Count:1 | yes Evaluation Count:26 |
| 1-26 |
| 1854 | qWarning("QObject event transitions are not supported for custom types"); executed (the execution status of this line is deduced): QMessageLogger("statemachine/qstatemachine.cpp", 1854, __PRETTY_FUNCTION__).warning("QObject event transitions are not supported for custom types"); | - |
| 1855 | return; executed: return;Execution Count:1 | 1 |
| 1856 | } | - |
| 1857 | QObject *object = QEventTransitionPrivate::get(transition)->object; executed (the execution status of this line is deduced): QObject *object = QEventTransitionPrivate::get(transition)->object; | - |
| 1858 | if (!object) partially evaluated: !object| no Evaluation Count:0 | yes Evaluation Count:26 |
| 0-26 |
| 1859 | return; | 0 |
| 1860 | QObjectPrivate *od = QObjectPrivate::get(object); executed (the execution status of this line is deduced): QObjectPrivate *od = QObjectPrivate::get(object); | - |
| 1861 | if (!od->extraData || !od->extraData->eventFilters.contains(q)) evaluated: !od->extraData| yes Evaluation Count:5 | yes Evaluation Count:21 |
evaluated: !od->extraData->eventFilters.contains(q)| yes Evaluation Count:14 | yes Evaluation Count:7 |
| 5-21 |
| 1862 | object->installEventFilter(q); executed: object->installEventFilter(q);Execution Count:19 | 19 |
| 1863 | ++qobjectEvents[object][transition->eventType()]; executed (the execution status of this line is deduced): ++qobjectEvents[object][transition->eventType()]; | - |
| 1864 | QEventTransitionPrivate::get(transition)->registered = true; executed (the execution status of this line is deduced): QEventTransitionPrivate::get(transition)->registered = true; | - |
| 1865 | #ifdef QSTATEMACHINE_DEBUG | - |
| 1866 | qDebug() << q << ": added event transition from" << transition->sourceState() | - |
| 1867 | << ": ( object =" << object << ", event =" << transition->eventType() | - |
| 1868 | << ", targets =" << transition->targetStates() << ')'; | - |
| 1869 | #endif | - |
| 1870 | } executed: }Execution Count:26 | 26 |
| 1871 | | - |
| 1872 | void QStateMachinePrivate::unregisterEventTransition(QEventTransition *transition) | - |
| 1873 | { | - |
| 1874 | Q_Q(QStateMachine); executed (the execution status of this line is deduced): QStateMachine * const q = q_func(); | - |
| 1875 | if (!QEventTransitionPrivate::get(transition)->registered) partially evaluated: !QEventTransitionPrivate::get(transition)->registered| no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
| 1876 | return; | 0 |
| 1877 | QObject *object = QEventTransitionPrivate::get(transition)->object; executed (the execution status of this line is deduced): QObject *object = QEventTransitionPrivate::get(transition)->object; | - |
| 1878 | QHash<QEvent::Type, int> &events = qobjectEvents[object]; executed (the execution status of this line is deduced): QHash<QEvent::Type, int> &events = qobjectEvents[object]; | - |
| 1879 | Q_ASSERT(events.value(transition->eventType()) > 0); executed (the execution status of this line is deduced): qt_noop(); | - |
| 1880 | if (--events[transition->eventType()] == 0) { evaluated: --events[transition->eventType()] == 0| yes Evaluation Count:19 | yes Evaluation Count:1 |
| 1-19 |
| 1881 | events.remove(transition->eventType()); executed (the execution status of this line is deduced): events.remove(transition->eventType()); | - |
| 1882 | int sum = 0; executed (the execution status of this line is deduced): int sum = 0; | - |
| 1883 | QHash<QEvent::Type, int>::const_iterator it; executed (the execution status of this line is deduced): QHash<QEvent::Type, int>::const_iterator it; | - |
| 1884 | for (it = events.constBegin(); it != events.constEnd(); ++it) evaluated: it != events.constEnd()| yes Evaluation Count:3 | yes Evaluation Count:19 |
| 3-19 |
| 1885 | sum += it.value(); executed: sum += it.value();Execution Count:3 | 3 |
| 1886 | if (sum == 0) { evaluated: sum == 0| yes Evaluation Count:16 | yes Evaluation Count:3 |
| 3-16 |
| 1887 | qobjectEvents.remove(object); executed (the execution status of this line is deduced): qobjectEvents.remove(object); | - |
| 1888 | object->removeEventFilter(q); executed (the execution status of this line is deduced): object->removeEventFilter(q); | - |
| 1889 | } executed: }Execution Count:16 | 16 |
| 1890 | } executed: }Execution Count:19 | 19 |
| 1891 | QEventTransitionPrivate::get(transition)->registered = false; executed (the execution status of this line is deduced): QEventTransitionPrivate::get(transition)->registered = false; | - |
| 1892 | } executed: }Execution Count:20 | 20 |
| 1893 | | - |
| 1894 | void QStateMachinePrivate::handleFilteredEvent(QObject *watched, QEvent *event) | - |
| 1895 | { | - |
| 1896 | if (qobjectEvents.value(watched).contains(event->type())) { evaluated: qobjectEvents.value(watched).contains(event->type())| yes Evaluation Count:25 | yes Evaluation Count:2 |
| 2-25 |
| 1897 | postInternalEvent(new QStateMachine::WrappedEvent(watched, handler->cloneEvent(event))); executed (the execution status of this line is deduced): postInternalEvent(new QStateMachine::WrappedEvent(watched, handler->cloneEvent(event))); | - |
| 1898 | processEvents(DirectProcessing); executed (the execution status of this line is deduced): processEvents(DirectProcessing); | - |
| 1899 | } executed: }Execution Count:25 | 25 |
| 1900 | } executed: }Execution Count:27 | 27 |
| 1901 | #endif | - |
| 1902 | | - |
| 1903 | void QStateMachinePrivate::handleTransitionSignal(QObject *sender, int signalIndex, | - |
| 1904 | void **argv) | - |
| 1905 | { | - |
| 1906 | #ifndef QT_NO_DEBUG | - |
| 1907 | connectionsMutex.lock(); | - |
| 1908 | Q_ASSERT(connections[sender].at(signalIndex) != 0); | - |
| 1909 | connectionsMutex.unlock(); | - |
| 1910 | #endif | - |
| 1911 | const QMetaObject *meta = sender->metaObject(); executed (the execution status of this line is deduced): const QMetaObject *meta = sender->metaObject(); | - |
| 1912 | QMetaMethod method = meta->method(signalIndex); executed (the execution status of this line is deduced): QMetaMethod method = meta->method(signalIndex); | - |
| 1913 | int argc = method.parameterCount(); executed (the execution status of this line is deduced): int argc = method.parameterCount(); | - |
| 1914 | QList<QVariant> vargs; executed (the execution status of this line is deduced): QList<QVariant> vargs; | - |
| 1915 | for (int i = 0; i < argc; ++i) { evaluated: i < argc| yes Evaluation Count:8 | yes Evaluation Count:62 |
| 8-62 |
| 1916 | int type = method.parameterType(i); executed (the execution status of this line is deduced): int type = method.parameterType(i); | - |
| 1917 | vargs.append(QVariant(type, argv[i+1])); executed (the execution status of this line is deduced): vargs.append(QVariant(type, argv[i+1])); | - |
| 1918 | } executed: }Execution Count:8 | 8 |
| 1919 | | - |
| 1920 | #ifdef QSTATEMACHINE_DEBUG | - |
| 1921 | qDebug() << q_func() << ": sending signal event ( sender =" << sender | - |
| 1922 | << ", signal =" << method.methodSignature().constData() << ')'; | - |
| 1923 | #endif | - |
| 1924 | postInternalEvent(new QStateMachine::SignalEvent(sender, signalIndex, vargs)); executed (the execution status of this line is deduced): postInternalEvent(new QStateMachine::SignalEvent(sender, signalIndex, vargs)); | - |
| 1925 | processEvents(DirectProcessing); executed (the execution status of this line is deduced): processEvents(DirectProcessing); | - |
| 1926 | } executed: }Execution Count:62 | 62 |
| 1927 | | - |
| 1928 | /*! | - |
| 1929 | Constructs a new state machine with the given \a parent. | - |
| 1930 | */ | - |
| 1931 | QStateMachine::QStateMachine(QObject *parent) | - |
| 1932 | : QState(*new QStateMachinePrivate, /*parentState=*/0) | - |
| 1933 | { | - |
| 1934 | // Can't pass the parent to the QState constructor, as it expects a QState | - |
| 1935 | // But this works as expected regardless of whether parent is a QState or not | - |
| 1936 | setParent(parent); executed (the execution status of this line is deduced): setParent(parent); | - |
| 1937 | } executed: }Execution Count:128 | 128 |
| 1938 | | - |
| 1939 | /*! | - |
| 1940 | \since 5.0 | - |
| 1941 | | - |
| 1942 | Constructs a new state machine with the given \a childMode | - |
| 1943 | and \a parent. | - |
| 1944 | */ | - |
| 1945 | QStateMachine::QStateMachine(QState::ChildMode childMode, QObject *parent) | - |
| 1946 | : QState(*new QStateMachinePrivate, /*parentState=*/0) | - |
| 1947 | { | - |
| 1948 | Q_D(QStateMachine); executed (the execution status of this line is deduced): QStateMachinePrivate * const d = d_func(); | - |
| 1949 | d->childMode = childMode; executed (the execution status of this line is deduced): d->childMode = childMode; | - |
| 1950 | setParent(parent); // See comment in constructor above executed (the execution status of this line is deduced): setParent(parent); | - |
| 1951 | } executed: }Execution Count:6 | 6 |
| 1952 | | - |
| 1953 | /*! | - |
| 1954 | \internal | - |
| 1955 | */ | - |
| 1956 | QStateMachine::QStateMachine(QStateMachinePrivate &dd, QObject *parent) | - |
| 1957 | : QState(dd, /*parentState=*/0) | - |
| 1958 | { | - |
| 1959 | setParent(parent); never executed (the execution status of this line is deduced): setParent(parent); | - |
| 1960 | } | 0 |
| 1961 | | - |
| 1962 | /*! | - |
| 1963 | Destroys this state machine. | - |
| 1964 | */ | - |
| 1965 | QStateMachine::~QStateMachine() | - |
| 1966 | { | - |
| 1967 | } | - |
| 1968 | | - |
| 1969 | /*! | - |
| 1970 | \enum QStateMachine::EventPriority | - |
| 1971 | | - |
| 1972 | This enum type specifies the priority of an event posted to the state | - |
| 1973 | machine using postEvent(). | - |
| 1974 | | - |
| 1975 | Events of high priority are processed before events of normal priority. | - |
| 1976 | | - |
| 1977 | \value NormalPriority The event has normal priority. | - |
| 1978 | \value HighPriority The event has high priority. | - |
| 1979 | */ | - |
| 1980 | | - |
| 1981 | /*! \enum QStateMachine::Error | - |
| 1982 | | - |
| 1983 | This enum type defines errors that can occur in the state machine at run time. When the state | - |
| 1984 | machine encounters an unrecoverable error at run time, it will set the error code returned | - |
| 1985 | by error(), the error message returned by errorString(), and enter an error state based on | - |
| 1986 | the context of the error. | - |
| 1987 | | - |
| 1988 | \value NoError No error has occurred. | - |
| 1989 | \value NoInitialStateError The machine has entered a QState with children which does not have an | - |
| 1990 | initial state set. The context of this error is the state which is missing an initial | - |
| 1991 | state. | - |
| 1992 | \value NoDefaultStateInHistoryStateError The machine has entered a QHistoryState which does not have | - |
| 1993 | a default state set. The context of this error is the QHistoryState which is missing a | - |
| 1994 | default state. | - |
| 1995 | \value NoCommonAncestorForTransitionError The machine has selected a transition whose source | - |
| 1996 | and targets are not part of the same tree of states, and thus are not part of the same | - |
| 1997 | state machine. Commonly, this could mean that one of the states has not been given | - |
| 1998 | any parent or added to any machine. The context of this error is the source state of | - |
| 1999 | the transition. | - |
| 2000 | | - |
| 2001 | \sa setErrorState() | - |
| 2002 | */ | - |
| 2003 | | - |
| 2004 | /*! | - |
| 2005 | Returns the error code of the last error that occurred in the state machine. | - |
| 2006 | */ | - |
| 2007 | QStateMachine::Error QStateMachine::error() const | - |
| 2008 | { | - |
| 2009 | Q_D(const QStateMachine); executed (the execution status of this line is deduced): const QStateMachinePrivate * const d = d_func(); | - |
| 2010 | return d->error; executed: return d->error;Execution Count:13 | 13 |
| 2011 | } | - |
| 2012 | | - |
| 2013 | /*! | - |
| 2014 | Returns the error string of the last error that occurred in the state machine. | - |
| 2015 | */ | - |
| 2016 | QString QStateMachine::errorString() const | - |
| 2017 | { | - |
| 2018 | Q_D(const QStateMachine); executed (the execution status of this line is deduced): const QStateMachinePrivate * const d = d_func(); | - |
| 2019 | return d->errorString; executed: return d->errorString;Execution Count:11 | 11 |
| 2020 | } | - |
| 2021 | | - |
| 2022 | /*! | - |
| 2023 | Clears the error string and error code of the state machine. | - |
| 2024 | */ | - |
| 2025 | void QStateMachine::clearError() | - |
| 2026 | { | - |
| 2027 | Q_D(QStateMachine); executed (the execution status of this line is deduced): QStateMachinePrivate * const d = d_func(); | - |
| 2028 | d->errorString.clear(); executed (the execution status of this line is deduced): d->errorString.clear(); | - |
| 2029 | d->error = NoError; executed (the execution status of this line is deduced): d->error = NoError; | - |
| 2030 | } executed: }Execution Count:1 | 1 |
| 2031 | | - |
| 2032 | /*! | - |
| 2033 | Returns the restore policy of the state machine. | - |
| 2034 | | - |
| 2035 | \sa setGlobalRestorePolicy() | - |
| 2036 | */ | - |
| 2037 | QState::RestorePolicy QStateMachine::globalRestorePolicy() const | - |
| 2038 | { | - |
| 2039 | Q_D(const QStateMachine); executed (the execution status of this line is deduced): const QStateMachinePrivate * const d = d_func(); | - |
| 2040 | return d->globalRestorePolicy; executed: return d->globalRestorePolicy;Execution Count:1 | 1 |
| 2041 | } | - |
| 2042 | | - |
| 2043 | /*! | - |
| 2044 | Sets the restore policy of the state machine to \a restorePolicy. The default | - |
| 2045 | restore policy is QState::DontRestoreProperties. | - |
| 2046 | | - |
| 2047 | \sa globalRestorePolicy() | - |
| 2048 | */ | - |
| 2049 | void QStateMachine::setGlobalRestorePolicy(QState::RestorePolicy restorePolicy) | - |
| 2050 | { | - |
| 2051 | Q_D(QStateMachine); executed (the execution status of this line is deduced): QStateMachinePrivate * const d = d_func(); | - |
| 2052 | d->globalRestorePolicy = restorePolicy; executed (the execution status of this line is deduced): d->globalRestorePolicy = restorePolicy; | - |
| 2053 | } executed: }Execution Count:18 | 18 |
| 2054 | | - |
| 2055 | /*! | - |
| 2056 | Adds the given \a state to this state machine. The state becomes a top-level | - |
| 2057 | state. | - |
| 2058 | | - |
| 2059 | If the state is already in a different machine, it will first be removed | - |
| 2060 | from its old machine, and then added to this machine. | - |
| 2061 | | - |
| 2062 | \sa removeState(), setInitialState() | - |
| 2063 | */ | - |
| 2064 | void QStateMachine::addState(QAbstractState *state) | - |
| 2065 | { | - |
| 2066 | if (!state) { partially evaluated: !state| no Evaluation Count:0 | yes Evaluation Count:42 |
| 0-42 |
| 2067 | qWarning("QStateMachine::addState: cannot add null state"); never executed (the execution status of this line is deduced): QMessageLogger("statemachine/qstatemachine.cpp", 2067, __PRETTY_FUNCTION__).warning("QStateMachine::addState: cannot add null state"); | - |
| 2068 | return; | 0 |
| 2069 | } | - |
| 2070 | if (QAbstractStatePrivate::get(state)->machine() == this) { partially evaluated: QAbstractStatePrivate::get(state)->machine() == this| no Evaluation Count:0 | yes Evaluation Count:42 |
| 0-42 |
| 2071 | qWarning("QStateMachine::addState: state has already been added to this machine"); never executed (the execution status of this line is deduced): QMessageLogger("statemachine/qstatemachine.cpp", 2071, __PRETTY_FUNCTION__).warning("QStateMachine::addState: state has already been added to this machine"); | - |
| 2072 | return; | 0 |
| 2073 | } | - |
| 2074 | state->setParent(this); executed (the execution status of this line is deduced): state->setParent(this); | - |
| 2075 | } executed: }Execution Count:42 | 42 |
| 2076 | | - |
| 2077 | /*! | - |
| 2078 | Removes the given \a state from this state machine. The state machine | - |
| 2079 | releases ownership of the state. | - |
| 2080 | | - |
| 2081 | \sa addState() | - |
| 2082 | */ | - |
| 2083 | void QStateMachine::removeState(QAbstractState *state) | - |
| 2084 | { | - |
| 2085 | if (!state) { | 0 |
| 2086 | qWarning("QStateMachine::removeState: cannot remove null state"); never executed (the execution status of this line is deduced): QMessageLogger("statemachine/qstatemachine.cpp", 2086, __PRETTY_FUNCTION__).warning("QStateMachine::removeState: cannot remove null state"); | - |
| 2087 | return; | 0 |
| 2088 | } | - |
| 2089 | if (QAbstractStatePrivate::get(state)->machine() != this) { never evaluated: QAbstractStatePrivate::get(state)->machine() != this | 0 |
| 2090 | qWarning("QStateMachine::removeState: state %p's machine (%p)" never executed (the execution status of this line is deduced): QMessageLogger("statemachine/qstatemachine.cpp", 2090, __PRETTY_FUNCTION__).warning("QStateMachine::removeState: state %p's machine (%p)" | - |
| 2091 | " is different from this machine (%p)", never executed (the execution status of this line is deduced): " is different from this machine (%p)", | - |
| 2092 | state, QAbstractStatePrivate::get(state)->machine(), this); never executed (the execution status of this line is deduced): state, QAbstractStatePrivate::get(state)->machine(), this); | - |
| 2093 | return; | 0 |
| 2094 | } | - |
| 2095 | state->setParent(0); never executed (the execution status of this line is deduced): state->setParent(0); | - |
| 2096 | } | 0 |
| 2097 | | - |
| 2098 | /*! | - |
| 2099 | Returns whether this state machine is running. | - |
| 2100 | | - |
| 2101 | \sa start(), stop() | - |
| 2102 | */ | - |
| 2103 | bool QStateMachine::isRunning() const | - |
| 2104 | { | - |
| 2105 | Q_D(const QStateMachine); executed (the execution status of this line is deduced): const QStateMachinePrivate * const d = d_func(); | - |
| 2106 | return (d->state == QStateMachinePrivate::Running); executed: return (d->state == QStateMachinePrivate::Running);Execution Count:25 | 25 |
| 2107 | } | - |
| 2108 | | - |
| 2109 | /*! | - |
| 2110 | Starts this state machine. The machine will reset its configuration and | - |
| 2111 | transition to the initial state. When a final top-level state (QFinalState) | - |
| 2112 | is entered, the machine will emit the finished() signal. | - |
| 2113 | | - |
| 2114 | \note A state machine will not run without a running event loop, such as | - |
| 2115 | the main application event loop started with QCoreApplication::exec() or | - |
| 2116 | QApplication::exec(). | - |
| 2117 | | - |
| 2118 | \sa started(), finished(), stop(), initialState() | - |
| 2119 | */ | - |
| 2120 | void QStateMachine::start() | - |
| 2121 | { | - |
| 2122 | Q_D(QStateMachine); executed (the execution status of this line is deduced): QStateMachinePrivate * const d = d_func(); | - |
| 2123 | | - |
| 2124 | if ((childMode() == QState::ExclusiveStates) && (initialState() == 0)) { evaluated: (childMode() == QState::ExclusiveStates)| yes Evaluation Count:145 | yes Evaluation Count:1 |
evaluated: (initialState() == 0)| yes Evaluation Count:2 | yes Evaluation Count:143 |
| 1-145 |
| 2125 | qWarning("QStateMachine::start: No initial state set for machine. Refusing to start."); executed (the execution status of this line is deduced): QMessageLogger("statemachine/qstatemachine.cpp", 2125, __PRETTY_FUNCTION__).warning("QStateMachine::start: No initial state set for machine. Refusing to start."); | - |
| 2126 | return; executed: return;Execution Count:2 | 2 |
| 2127 | } | - |
| 2128 | | - |
| 2129 | switch (d->state) { | - |
| 2130 | case QStateMachinePrivate::NotRunning: | - |
| 2131 | d->state = QStateMachinePrivate::Starting; executed (the execution status of this line is deduced): d->state = QStateMachinePrivate::Starting; | - |
| 2132 | QMetaObject::invokeMethod(this, "_q_start", Qt::QueuedConnection); executed (the execution status of this line is deduced): QMetaObject::invokeMethod(this, "_q_start", Qt::QueuedConnection); | - |
| 2133 | break; executed: break;Execution Count:143 | 143 |
| 2134 | case QStateMachinePrivate::Starting: | - |
| 2135 | break; | 0 |
| 2136 | case QStateMachinePrivate::Running: | - |
| 2137 | qWarning("QStateMachine::start(): already running"); executed (the execution status of this line is deduced): QMessageLogger("statemachine/qstatemachine.cpp", 2137, __PRETTY_FUNCTION__).warning("QStateMachine::start(): already running"); | - |
| 2138 | break; executed: break;Execution Count:1 | 1 |
| 2139 | } | - |
| 2140 | } executed: }Execution Count:144 | 144 |
| 2141 | | - |
| 2142 | /*! | - |
| 2143 | Stops this state machine. The state machine will stop processing events and | - |
| 2144 | then emit the stopped() signal. | - |
| 2145 | | - |
| 2146 | \sa stopped(), start() | - |
| 2147 | */ | - |
| 2148 | void QStateMachine::stop() | - |
| 2149 | { | - |
| 2150 | Q_D(QStateMachine); executed (the execution status of this line is deduced): QStateMachinePrivate * const d = d_func(); | - |
| 2151 | switch (d->state) { | - |
| 2152 | case QStateMachinePrivate::NotRunning: | - |
| 2153 | break; executed: break;Execution Count:4 | 4 |
| 2154 | case QStateMachinePrivate::Starting: | - |
| 2155 | // the machine will exit as soon as it enters the event processing loop | - |
| 2156 | d->stop = true; executed (the execution status of this line is deduced): d->stop = true; | - |
| 2157 | break; executed: break;Execution Count:1 | 1 |
| 2158 | case QStateMachinePrivate::Running: | - |
| 2159 | d->stop = true; executed (the execution status of this line is deduced): d->stop = true; | - |
| 2160 | d->processEvents(QStateMachinePrivate::QueuedProcessing); executed (the execution status of this line is deduced): d->processEvents(QStateMachinePrivate::QueuedProcessing); | - |
| 2161 | break; executed: break;Execution Count:19 | 19 |
| 2162 | } | - |
| 2163 | } executed: }Execution Count:24 | 24 |
| 2164 | | - |
| 2165 | /*! | - |
| 2166 | \threadsafe | - |
| 2167 | | - |
| 2168 | Posts the given \a event of the given \a priority for processing by this | - |
| 2169 | state machine. | - |
| 2170 | | - |
| 2171 | This function returns immediately. The event is added to the state machine's | - |
| 2172 | event queue. Events are processed in the order posted. The state machine | - |
| 2173 | takes ownership of the event and deletes it once it has been processed. | - |
| 2174 | | - |
| 2175 | You can only post events when the state machine is running. | - |
| 2176 | | - |
| 2177 | \sa postDelayedEvent() | - |
| 2178 | */ | - |
| 2179 | void QStateMachine::postEvent(QEvent *event, EventPriority priority) | - |
| 2180 | { | - |
| 2181 | Q_D(QStateMachine); executed (the execution status of this line is deduced): QStateMachinePrivate * const d = d_func(); | - |
| 2182 | if (d->state != QStateMachinePrivate::Running) { evaluated: d->state != QStateMachinePrivate::Running| yes Evaluation Count:2 | yes Evaluation Count:2119 |
| 2-2119 |
| 2183 | qWarning("QStateMachine::postEvent: cannot post event when the state machine is not running"); executed (the execution status of this line is deduced): QMessageLogger("statemachine/qstatemachine.cpp", 2183, __PRETTY_FUNCTION__).warning("QStateMachine::postEvent: cannot post event when the state machine is not running"); | - |
| 2184 | return; executed: return;Execution Count:2 | 2 |
| 2185 | } | - |
| 2186 | if (!event) { partially evaluated: !event| no Evaluation Count:0 | yes Evaluation Count:2119 |
| 0-2119 |
| 2187 | qWarning("QStateMachine::postEvent: cannot post null event"); never executed (the execution status of this line is deduced): QMessageLogger("statemachine/qstatemachine.cpp", 2187, __PRETTY_FUNCTION__).warning("QStateMachine::postEvent: cannot post null event"); | - |
| 2188 | return; | 0 |
| 2189 | } | - |
| 2190 | #ifdef QSTATEMACHINE_DEBUG | - |
| 2191 | qDebug() << this << ": posting event" << event; | - |
| 2192 | #endif | - |
| 2193 | switch (priority) { | - |
| 2194 | case NormalPriority: | - |
| 2195 | d->postExternalEvent(event); executed (the execution status of this line is deduced): d->postExternalEvent(event); | - |
| 2196 | break; executed: break;Execution Count:2118 | 2118 |
| 2197 | case HighPriority: | - |
| 2198 | d->postInternalEvent(event); executed (the execution status of this line is deduced): d->postInternalEvent(event); | - |
| 2199 | break; executed: break;Execution Count:1 | 1 |
| 2200 | } | - |
| 2201 | d->processEvents(QStateMachinePrivate::QueuedProcessing); executed (the execution status of this line is deduced): d->processEvents(QStateMachinePrivate::QueuedProcessing); | - |
| 2202 | } executed: }Execution Count:2119 | 2119 |
| 2203 | | - |
| 2204 | /*! | - |
| 2205 | \threadsafe | - |
| 2206 | | - |
| 2207 | Posts the given \a event for processing by this state machine, with the | - |
| 2208 | given \a delay in milliseconds. Returns an identifier associated with the | - |
| 2209 | delayed event, or -1 if the event could not be posted. | - |
| 2210 | | - |
| 2211 | This function returns immediately. When the delay has expired, the event | - |
| 2212 | will be added to the state machine's event queue for processing. The state | - |
| 2213 | machine takes ownership of the event and deletes it once it has been | - |
| 2214 | processed. | - |
| 2215 | | - |
| 2216 | You can only post events when the state machine is running. | - |
| 2217 | | - |
| 2218 | \sa cancelDelayedEvent(), postEvent() | - |
| 2219 | */ | - |
| 2220 | int QStateMachine::postDelayedEvent(QEvent *event, int delay) | - |
| 2221 | { | - |
| 2222 | Q_D(QStateMachine); executed (the execution status of this line is deduced): QStateMachinePrivate * const d = d_func(); | - |
| 2223 | if (d->state != QStateMachinePrivate::Running) { partially evaluated: d->state != QStateMachinePrivate::Running| no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
| 2224 | qWarning("QStateMachine::postDelayedEvent: cannot post event when the state machine is not running"); never executed (the execution status of this line is deduced): QMessageLogger("statemachine/qstatemachine.cpp", 2224, __PRETTY_FUNCTION__).warning("QStateMachine::postDelayedEvent: cannot post event when the state machine is not running"); | - |
| 2225 | return -1; never executed: return -1; | 0 |
| 2226 | } | - |
| 2227 | if (!event) { partially evaluated: !event| no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
| 2228 | qWarning("QStateMachine::postDelayedEvent: cannot post null event"); never executed (the execution status of this line is deduced): QMessageLogger("statemachine/qstatemachine.cpp", 2228, __PRETTY_FUNCTION__).warning("QStateMachine::postDelayedEvent: cannot post null event"); | - |
| 2229 | return -1; never executed: return -1; | 0 |
| 2230 | } | - |
| 2231 | if (delay < 0) { partially evaluated: delay < 0| no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
| 2232 | qWarning("QStateMachine::postDelayedEvent: delay cannot be negative"); never executed (the execution status of this line is deduced): QMessageLogger("statemachine/qstatemachine.cpp", 2232, __PRETTY_FUNCTION__).warning("QStateMachine::postDelayedEvent: delay cannot be negative"); | - |
| 2233 | return -1; never executed: return -1; | 0 |
| 2234 | } | - |
| 2235 | #ifdef QSTATEMACHINE_DEBUG | - |
| 2236 | qDebug() << this << ": posting event" << event << "with delay" << delay; | - |
| 2237 | #endif | - |
| 2238 | QMutexLocker locker(&d->delayedEventsMutex); executed (the execution status of this line is deduced): QMutexLocker locker(&d->delayedEventsMutex); | - |
| 2239 | int id = d->delayedEventIdFreeList.next(); executed (the execution status of this line is deduced): int id = d->delayedEventIdFreeList.next(); | - |
| 2240 | bool inMachineThread = (QThread::currentThread() == thread()); executed (the execution status of this line is deduced): bool inMachineThread = (QThread::currentThread() == thread()); | - |
| 2241 | int timerId = inMachineThread ? startTimer(delay) : 0; evaluated: inMachineThread| yes Evaluation Count:7 | yes Evaluation Count:2 |
| 2-7 |
| 2242 | if (inMachineThread && !timerId) { evaluated: inMachineThread| yes Evaluation Count:7 | yes Evaluation Count:2 |
partially evaluated: !timerId| no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
| 2243 | qWarning("QStateMachine::postDelayedEvent: failed to start timer with interval %d", delay); never executed (the execution status of this line is deduced): QMessageLogger("statemachine/qstatemachine.cpp", 2243, __PRETTY_FUNCTION__).warning("QStateMachine::postDelayedEvent: failed to start timer with interval %d", delay); | - |
| 2244 | d->delayedEventIdFreeList.release(id); never executed (the execution status of this line is deduced): d->delayedEventIdFreeList.release(id); | - |
| 2245 | return -1; never executed: return -1; | 0 |
| 2246 | } | - |
| 2247 | QStateMachinePrivate::DelayedEvent delayedEvent(event, timerId); executed (the execution status of this line is deduced): QStateMachinePrivate::DelayedEvent delayedEvent(event, timerId); | - |
| 2248 | d->delayedEvents.insert(id, delayedEvent); executed (the execution status of this line is deduced): d->delayedEvents.insert(id, delayedEvent); | - |
| 2249 | if (timerId) { evaluated: timerId| yes Evaluation Count:7 | yes Evaluation Count:2 |
| 2-7 |
| 2250 | d->timerIdToDelayedEventId.insert(timerId, id); executed (the execution status of this line is deduced): d->timerIdToDelayedEventId.insert(timerId, id); | - |
| 2251 | } else { executed: }Execution Count:7 | 7 |
| 2252 | Q_ASSERT(!inMachineThread); executed (the execution status of this line is deduced): qt_noop(); | - |
| 2253 | QMetaObject::invokeMethod(this, "_q_startDelayedEventTimer", executed (the execution status of this line is deduced): QMetaObject::invokeMethod(this, "_q_startDelayedEventTimer", | - |
| 2254 | Qt::QueuedConnection, executed (the execution status of this line is deduced): Qt::QueuedConnection, | - |
| 2255 | Q_ARG(int, id), executed (the execution status of this line is deduced): QArgument<int >("int", id), | - |
| 2256 | Q_ARG(int, delay)); executed (the execution status of this line is deduced): QArgument<int >("int", delay)); | - |
| 2257 | } executed: }Execution Count:2 | 2 |
| 2258 | return id; executed: return id;Execution Count:9 | 9 |
| 2259 | } | - |
| 2260 | | - |
| 2261 | /*! | - |
| 2262 | \threadsafe | - |
| 2263 | | - |
| 2264 | Cancels the delayed event identified by the given \a id. The id should be a | - |
| 2265 | value returned by a call to postDelayedEvent(). Returns true if the event | - |
| 2266 | was successfully cancelled, otherwise returns false. | - |
| 2267 | | - |
| 2268 | \sa postDelayedEvent() | - |
| 2269 | */ | - |
| 2270 | bool QStateMachine::cancelDelayedEvent(int id) | - |
| 2271 | { | - |
| 2272 | Q_D(QStateMachine); executed (the execution status of this line is deduced): QStateMachinePrivate * const d = d_func(); | - |
| 2273 | if (d->state != QStateMachinePrivate::Running) { evaluated: d->state != QStateMachinePrivate::Running| yes Evaluation Count:1 | yes Evaluation Count:5 |
| 1-5 |
| 2274 | qWarning("QStateMachine::cancelDelayedEvent: the machine is not running"); executed (the execution status of this line is deduced): QMessageLogger("statemachine/qstatemachine.cpp", 2274, __PRETTY_FUNCTION__).warning("QStateMachine::cancelDelayedEvent: the machine is not running"); | - |
| 2275 | return false; executed: return false;Execution Count:1 | 1 |
| 2276 | } | - |
| 2277 | QMutexLocker locker(&d->delayedEventsMutex); executed (the execution status of this line is deduced): QMutexLocker locker(&d->delayedEventsMutex); | - |
| 2278 | QStateMachinePrivate::DelayedEvent e = d->delayedEvents.take(id); executed (the execution status of this line is deduced): QStateMachinePrivate::DelayedEvent e = d->delayedEvents.take(id); | - |
| 2279 | if (!e.event) evaluated: !e.event| yes Evaluation Count:2 | yes Evaluation Count:3 |
| 2-3 |
| 2280 | return false; executed: return false;Execution Count:2 | 2 |
| 2281 | if (e.timerId) { evaluated: e.timerId| yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
| 2282 | d->timerIdToDelayedEventId.remove(e.timerId); executed (the execution status of this line is deduced): d->timerIdToDelayedEventId.remove(e.timerId); | - |
| 2283 | bool inMachineThread = (QThread::currentThread() == thread()); executed (the execution status of this line is deduced): bool inMachineThread = (QThread::currentThread() == thread()); | - |
| 2284 | if (inMachineThread) { partially evaluated: inMachineThread| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
| 2285 | killTimer(e.timerId); executed (the execution status of this line is deduced): killTimer(e.timerId); | - |
| 2286 | d->delayedEventIdFreeList.release(id); executed (the execution status of this line is deduced): d->delayedEventIdFreeList.release(id); | - |
| 2287 | } else { executed: }Execution Count:2 | 2 |
| 2288 | QMetaObject::invokeMethod(this, "_q_killDelayedEventTimer", never executed (the execution status of this line is deduced): QMetaObject::invokeMethod(this, "_q_killDelayedEventTimer", | - |
| 2289 | Qt::QueuedConnection, never executed (the execution status of this line is deduced): Qt::QueuedConnection, | - |
| 2290 | Q_ARG(int, id), never executed (the execution status of this line is deduced): QArgument<int >("int", id), | - |
| 2291 | Q_ARG(int, e.timerId)); never executed (the execution status of this line is deduced): QArgument<int >("int", e.timerId)); | - |
| 2292 | } | 0 |
| 2293 | } else { | - |
| 2294 | // Cancellation will be detected in pending _q_startDelayedEventTimer() call | - |
| 2295 | } executed: }Execution Count:1 | 1 |
| 2296 | delete e.event; executed (the execution status of this line is deduced): delete e.event; | - |
| 2297 | return true; executed: return true;Execution Count:3 | 3 |
| 2298 | } | - |
| 2299 | | - |
| 2300 | /*! | - |
| 2301 | Returns the maximal consistent set of states (including parallel and final | - |
| 2302 | states) that this state machine is currently in. If a state \c s is in the | - |
| 2303 | configuration, it is always the case that the parent of \c s is also in | - |
| 2304 | c. Note, however, that the machine itself is not an explicit member of the | - |
| 2305 | configuration. | - |
| 2306 | */ | - |
| 2307 | QSet<QAbstractState*> QStateMachine::configuration() const | - |
| 2308 | { | - |
| 2309 | Q_D(const QStateMachine); executed (the execution status of this line is deduced): const QStateMachinePrivate * const d = d_func(); | - |
| 2310 | return d->configuration; executed: return d->configuration;Execution Count:469 | 469 |
| 2311 | } | - |
| 2312 | | - |
| 2313 | /*! | - |
| 2314 | \fn QStateMachine::started() | - |
| 2315 | | - |
| 2316 | This signal is emitted when the state machine has entered its initial state | - |
| 2317 | (QStateMachine::initialState). | - |
| 2318 | | - |
| 2319 | \sa QStateMachine::finished(), QStateMachine::start() | - |
| 2320 | */ | - |
| 2321 | | - |
| 2322 | /*! | - |
| 2323 | \fn QStateMachine::stopped() | - |
| 2324 | | - |
| 2325 | This signal is emitted when the state machine has stopped. | - |
| 2326 | | - |
| 2327 | \sa QStateMachine::stop(), QStateMachine::finished() | - |
| 2328 | */ | - |
| 2329 | | - |
| 2330 | /*! | - |
| 2331 | \reimp | - |
| 2332 | */ | - |
| 2333 | bool QStateMachine::event(QEvent *e) | - |
| 2334 | { | - |
| 2335 | Q_D(QStateMachine); executed (the execution status of this line is deduced): QStateMachinePrivate * const d = d_func(); | - |
| 2336 | if (e->type() == QEvent::Timer) { evaluated: e->type() == QEvent::Timer| yes Evaluation Count:4 | yes Evaluation Count:628 |
| 4-628 |
| 2337 | QTimerEvent *te = static_cast<QTimerEvent*>(e); executed (the execution status of this line is deduced): QTimerEvent *te = static_cast<QTimerEvent*>(e); | - |
| 2338 | int tid = te->timerId(); executed (the execution status of this line is deduced): int tid = te->timerId(); | - |
| 2339 | if (d->state != QStateMachinePrivate::Running) { partially evaluated: d->state != QStateMachinePrivate::Running| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 2340 | // This event has been cancelled already | - |
| 2341 | QMutexLocker locker(&d->delayedEventsMutex); never executed (the execution status of this line is deduced): QMutexLocker locker(&d->delayedEventsMutex); | - |
| 2342 | Q_ASSERT(!d->timerIdToDelayedEventId.contains(tid)); never executed (the execution status of this line is deduced): qt_noop(); | - |
| 2343 | return true; never executed: return true; | 0 |
| 2344 | } | - |
| 2345 | d->delayedEventsMutex.lock(); executed (the execution status of this line is deduced): d->delayedEventsMutex.lock(); | - |
| 2346 | int id = d->timerIdToDelayedEventId.take(tid); executed (the execution status of this line is deduced): int id = d->timerIdToDelayedEventId.take(tid); | - |
| 2347 | QStateMachinePrivate::DelayedEvent ee = d->delayedEvents.take(id); executed (the execution status of this line is deduced): QStateMachinePrivate::DelayedEvent ee = d->delayedEvents.take(id); | - |
| 2348 | if (ee.event != 0) { partially evaluated: ee.event != 0| yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
| 2349 | Q_ASSERT(ee.timerId == tid); executed (the execution status of this line is deduced): qt_noop(); | - |
| 2350 | killTimer(tid); executed (the execution status of this line is deduced): killTimer(tid); | - |
| 2351 | d->delayedEventIdFreeList.release(id); executed (the execution status of this line is deduced): d->delayedEventIdFreeList.release(id); | - |
| 2352 | d->delayedEventsMutex.unlock(); executed (the execution status of this line is deduced): d->delayedEventsMutex.unlock(); | - |
| 2353 | d->postExternalEvent(ee.event); executed (the execution status of this line is deduced): d->postExternalEvent(ee.event); | - |
| 2354 | d->processEvents(QStateMachinePrivate::DirectProcessing); executed (the execution status of this line is deduced): d->processEvents(QStateMachinePrivate::DirectProcessing); | - |
| 2355 | return true; executed: return true;Execution Count:4 | 4 |
| 2356 | } else { | - |
| 2357 | d->delayedEventsMutex.unlock(); never executed (the execution status of this line is deduced): d->delayedEventsMutex.unlock(); | - |
| 2358 | } | 0 |
| 2359 | } | - |
| 2360 | return QState::event(e); executed: return QState::event(e);Execution Count:628 | 628 |
| 2361 | } | - |
| 2362 | | - |
| 2363 | #ifndef QT_NO_STATEMACHINE_EVENTFILTER | - |
| 2364 | /*! | - |
| 2365 | \reimp | - |
| 2366 | */ | - |
| 2367 | bool QStateMachine::eventFilter(QObject *watched, QEvent *event) | - |
| 2368 | { | - |
| 2369 | Q_D(QStateMachine); executed (the execution status of this line is deduced): QStateMachinePrivate * const d = d_func(); | - |
| 2370 | d->handleFilteredEvent(watched, event); executed (the execution status of this line is deduced): d->handleFilteredEvent(watched, event); | - |
| 2371 | return false; executed: return false;Execution Count:27 | 27 |
| 2372 | } | - |
| 2373 | #endif | - |
| 2374 | | - |
| 2375 | /*! | - |
| 2376 | \internal | - |
| 2377 | | - |
| 2378 | This function is called when the state machine is about to select | - |
| 2379 | transitions based on the given \a event. | - |
| 2380 | | - |
| 2381 | The default implementation does nothing. | - |
| 2382 | */ | - |
| 2383 | void QStateMachine::beginSelectTransitions(QEvent *event) | - |
| 2384 | { | - |
| 2385 | Q_UNUSED(event); executed (the execution status of this line is deduced): (void)event;; | - |
| 2386 | } executed: }Execution Count:4709 | 4709 |
| 2387 | | - |
| 2388 | /*! | - |
| 2389 | \internal | - |
| 2390 | | - |
| 2391 | This function is called when the state machine has finished selecting | - |
| 2392 | transitions based on the given \a event. | - |
| 2393 | | - |
| 2394 | The default implementation does nothing. | - |
| 2395 | */ | - |
| 2396 | void QStateMachine::endSelectTransitions(QEvent *event) | - |
| 2397 | { | - |
| 2398 | Q_UNUSED(event); executed (the execution status of this line is deduced): (void)event;; | - |
| 2399 | } executed: }Execution Count:4709 | 4709 |
| 2400 | | - |
| 2401 | /*! | - |
| 2402 | \internal | - |
| 2403 | | - |
| 2404 | This function is called when the state machine is about to do a microstep. | - |
| 2405 | | - |
| 2406 | The default implementation does nothing. | - |
| 2407 | */ | - |
| 2408 | void QStateMachine::beginMicrostep(QEvent *event) | - |
| 2409 | { | - |
| 2410 | Q_UNUSED(event); executed (the execution status of this line is deduced): (void)event;; | - |
| 2411 | } executed: }Execution Count:1224 | 1224 |
| 2412 | | - |
| 2413 | /*! | - |
| 2414 | \internal | - |
| 2415 | | - |
| 2416 | This function is called when the state machine has finished doing a | - |
| 2417 | microstep. | - |
| 2418 | | - |
| 2419 | The default implementation does nothing. | - |
| 2420 | */ | - |
| 2421 | void QStateMachine::endMicrostep(QEvent *event) | - |
| 2422 | { | - |
| 2423 | Q_UNUSED(event); executed (the execution status of this line is deduced): (void)event;; | - |
| 2424 | } executed: }Execution Count:1224 | 1224 |
| 2425 | | - |
| 2426 | /*! | - |
| 2427 | \reimp | - |
| 2428 | This function will call start() to start the state machine. | - |
| 2429 | */ | - |
| 2430 | void QStateMachine::onEntry(QEvent *event) | - |
| 2431 | { | - |
| 2432 | start(); executed (the execution status of this line is deduced): start(); | - |
| 2433 | QState::onEntry(event); executed (the execution status of this line is deduced): QState::onEntry(event); | - |
| 2434 | } executed: }Execution Count:3 | 3 |
| 2435 | | - |
| 2436 | /*! | - |
| 2437 | \reimp | - |
| 2438 | This function will call stop() to stop the state machine and | - |
| 2439 | subsequently emit the stopped() signal. | - |
| 2440 | */ | - |
| 2441 | void QStateMachine::onExit(QEvent *event) | - |
| 2442 | { | - |
| 2443 | stop(); executed (the execution status of this line is deduced): stop(); | - |
| 2444 | QState::onExit(event); executed (the execution status of this line is deduced): QState::onExit(event); | - |
| 2445 | } executed: }Execution Count:3 | 3 |
| 2446 | | - |
| 2447 | #ifndef QT_NO_ANIMATION | - |
| 2448 | | - |
| 2449 | /*! | - |
| 2450 | Returns whether animations are enabled for this state machine. | - |
| 2451 | */ | - |
| 2452 | bool QStateMachine::isAnimated() const | - |
| 2453 | { | - |
| 2454 | Q_D(const QStateMachine); executed (the execution status of this line is deduced): const QStateMachinePrivate * const d = d_func(); | - |
| 2455 | return d->animated; executed: return d->animated;Execution Count:3 | 3 |
| 2456 | } | - |
| 2457 | | - |
| 2458 | /*! | - |
| 2459 | Sets whether animations are \a enabled for this state machine. | - |
| 2460 | */ | - |
| 2461 | void QStateMachine::setAnimated(bool enabled) | - |
| 2462 | { | - |
| 2463 | Q_D(QStateMachine); executed (the execution status of this line is deduced): QStateMachinePrivate * const d = d_func(); | - |
| 2464 | d->animated = enabled; executed (the execution status of this line is deduced): d->animated = enabled; | - |
| 2465 | } executed: }Execution Count:2 | 2 |
| 2466 | | - |
| 2467 | /*! | - |
| 2468 | Adds a default \a animation to be considered for any transition. | - |
| 2469 | */ | - |
| 2470 | void QStateMachine::addDefaultAnimation(QAbstractAnimation *animation) | - |
| 2471 | { | - |
| 2472 | Q_D(QStateMachine); executed (the execution status of this line is deduced): QStateMachinePrivate * const d = d_func(); | - |
| 2473 | d->defaultAnimations.append(animation); executed (the execution status of this line is deduced): d->defaultAnimations.append(animation); | - |
| 2474 | } executed: }Execution Count:9 | 9 |
| 2475 | | - |
| 2476 | /*! | - |
| 2477 | Returns the list of default animations that will be considered for any transition. | - |
| 2478 | */ | - |
| 2479 | QList<QAbstractAnimation*> QStateMachine::defaultAnimations() const | - |
| 2480 | { | - |
| 2481 | Q_D(const QStateMachine); executed (the execution status of this line is deduced): const QStateMachinePrivate * const d = d_func(); | - |
| 2482 | return d->defaultAnimations; executed: return d->defaultAnimations;Execution Count:10 | 10 |
| 2483 | } | - |
| 2484 | | - |
| 2485 | /*! | - |
| 2486 | Removes \a animation from the list of default animations. | - |
| 2487 | */ | - |
| 2488 | void QStateMachine::removeDefaultAnimation(QAbstractAnimation *animation) | - |
| 2489 | { | - |
| 2490 | Q_D(QStateMachine); executed (the execution status of this line is deduced): QStateMachinePrivate * const d = d_func(); | - |
| 2491 | d->defaultAnimations.removeAll(animation); executed (the execution status of this line is deduced): d->defaultAnimations.removeAll(animation); | - |
| 2492 | } executed: }Execution Count:3 | 3 |
| 2493 | | - |
| 2494 | #endif // QT_NO_ANIMATION | - |
| 2495 | | - |
| 2496 | | - |
| 2497 | // Begin moc-generated code -- modify carefully (check "HAND EDIT" parts)! | - |
| 2498 | struct qt_meta_stringdata_QSignalEventGenerator_t { | - |
| 2499 | QByteArrayData data[3]; | - |
| 2500 | char stringdata[32]; | - |
| 2501 | }; | - |
| 2502 | #define QT_MOC_LITERAL(idx, ofs, len) \ | - |
| 2503 | Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ | - |
| 2504 | offsetof(qt_meta_stringdata_QSignalEventGenerator_t, stringdata) + ofs \ | - |
| 2505 | - idx * sizeof(QByteArrayData) \ | - |
| 2506 | ) | - |
| 2507 | static const qt_meta_stringdata_QSignalEventGenerator_t qt_meta_stringdata_QSignalEventGenerator = { | - |
| 2508 | { | - |
| 2509 | QT_MOC_LITERAL(0, 0, 21), | - |
| 2510 | QT_MOC_LITERAL(1, 22, 7), | - |
| 2511 | QT_MOC_LITERAL(2, 30, 0) | - |
| 2512 | }, | - |
| 2513 | "QSignalEventGenerator\0execute\0\0" | - |
| 2514 | }; | - |
| 2515 | #undef QT_MOC_LITERAL | - |
| 2516 | | - |
| 2517 | static const uint qt_meta_data_QSignalEventGenerator[] = { | - |
| 2518 | | - |
| 2519 | // content: | - |
| 2520 | 7, // revision | - |
| 2521 | 0, // classname | - |
| 2522 | 0, 0, // classinfo | - |
| 2523 | 1, 14, // methods | - |
| 2524 | 0, 0, // properties | - |
| 2525 | 0, 0, // enums/sets | - |
| 2526 | 0, 0, // constructors | - |
| 2527 | 0, // flags | - |
| 2528 | 0, // signalCount | - |
| 2529 | | - |
| 2530 | // slots: name, argc, parameters, tag, flags | - |
| 2531 | 1, 0, 19, 2, 0x0a, | - |
| 2532 | | - |
| 2533 | // slots: parameters | - |
| 2534 | QMetaType::Void, | - |
| 2535 | | - |
| 2536 | 0 // eod | - |
| 2537 | }; | - |
| 2538 | | - |
| 2539 | void QSignalEventGenerator::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) | - |
| 2540 | { | - |
| 2541 | if (_c == QMetaObject::InvokeMetaMethod) { | - |
| 2542 | Q_ASSERT(staticMetaObject.cast(_o)); | - |
| 2543 | QSignalEventGenerator *_t = static_cast<QSignalEventGenerator *>(_o); | - |
| 2544 | switch (_id) { | - |
| 2545 | case 0: _t->execute(_a); break; // HAND EDIT: add the _a parameter | - |
| 2546 | default: ; | - |
| 2547 | } | - |
| 2548 | } | - |
| 2549 | Q_UNUSED(_a); | - |
| 2550 | } | - |
| 2551 | | - |
| 2552 | const QMetaObject QSignalEventGenerator::staticMetaObject = { | - |
| 2553 | { &QObject::staticMetaObject, qt_meta_stringdata_QSignalEventGenerator.data, | - |
| 2554 | qt_meta_data_QSignalEventGenerator, qt_static_metacall, 0, 0 } | - |
| 2555 | }; | - |
| 2556 | | - |
| 2557 | const QMetaObject *QSignalEventGenerator::metaObject() const | - |
| 2558 | { | - |
| 2559 | return &staticMetaObject; | - |
| 2560 | } | - |
| 2561 | | - |
| 2562 | void *QSignalEventGenerator::qt_metacast(const char *_clname) | - |
| 2563 | { | - |
| 2564 | if (!_clname) return 0; | - |
| 2565 | if (!strcmp(_clname, qt_meta_stringdata_QSignalEventGenerator.stringdata)) | - |
| 2566 | return static_cast<void*>(const_cast< QSignalEventGenerator*>(this)); | - |
| 2567 | return QObject::qt_metacast(_clname); | - |
| 2568 | } | - |
| 2569 | | - |
| 2570 | int QSignalEventGenerator::qt_metacall(QMetaObject::Call _c, int _id, void **_a) | - |
| 2571 | { | - |
| 2572 | _id = QObject::qt_metacall(_c, _id, _a); | - |
| 2573 | if (_id < 0) | - |
| 2574 | return _id; | - |
| 2575 | if (_c == QMetaObject::InvokeMetaMethod) { | - |
| 2576 | if (_id < 1) | - |
| 2577 | qt_static_metacall(this, _c, _id, _a); | - |
| 2578 | _id -= 1; | - |
| 2579 | } | - |
| 2580 | return _id; | - |
| 2581 | } | - |
| 2582 | // End moc-generated code | - |
| 2583 | | - |
| 2584 | void QSignalEventGenerator::execute(void **_a) | - |
| 2585 | { | - |
| 2586 | int signalIndex = senderSignalIndex(); executed (the execution status of this line is deduced): int signalIndex = senderSignalIndex(); | - |
| 2587 | Q_ASSERT(signalIndex != -1); executed (the execution status of this line is deduced): qt_noop(); | - |
| 2588 | QStateMachine *machine = qobject_cast<QStateMachine*>(parent()); executed (the execution status of this line is deduced): QStateMachine *machine = qobject_cast<QStateMachine*>(parent()); | - |
| 2589 | QStateMachinePrivate::get(machine)->handleTransitionSignal(sender(), signalIndex, _a); executed (the execution status of this line is deduced): QStateMachinePrivate::get(machine)->handleTransitionSignal(sender(), signalIndex, _a); | - |
| 2590 | } executed: }Execution Count:62 | 62 |
| 2591 | | - |
| 2592 | QSignalEventGenerator::QSignalEventGenerator(QStateMachine *parent) | - |
| 2593 | : QObject(parent) | - |
| 2594 | { | - |
| 2595 | } executed: }Execution Count:37 | 37 |
| 2596 | | - |
| 2597 | /*! | - |
| 2598 | \class QStateMachine::SignalEvent | - |
| 2599 | \inmodule QtCore | - |
| 2600 | | - |
| 2601 | \brief The SignalEvent class represents a Qt signal event. | - |
| 2602 | | - |
| 2603 | \since 4.6 | - |
| 2604 | \ingroup statemachine | - |
| 2605 | | - |
| 2606 | A signal event is generated by a QStateMachine in response to a Qt | - |
| 2607 | signal. The QSignalTransition class provides a transition associated with a | - |
| 2608 | signal event. QStateMachine::SignalEvent is part of \l{The State Machine Framework}. | - |
| 2609 | | - |
| 2610 | The sender() function returns the object that generated the signal. The | - |
| 2611 | signalIndex() function returns the index of the signal. The arguments() | - |
| 2612 | function returns the arguments of the signal. | - |
| 2613 | | - |
| 2614 | \sa QSignalTransition | - |
| 2615 | */ | - |
| 2616 | | - |
| 2617 | /*! | - |
| 2618 | \internal | - |
| 2619 | | - |
| 2620 | Constructs a new SignalEvent object with the given \a sender, \a | - |
| 2621 | signalIndex and \a arguments. | - |
| 2622 | */ | - |
| 2623 | QStateMachine::SignalEvent::SignalEvent(QObject *sender, int signalIndex, | - |
| 2624 | const QList<QVariant> &arguments) | - |
| 2625 | : QEvent(QEvent::StateMachineSignal), m_sender(sender), | - |
| 2626 | m_signalIndex(signalIndex), m_arguments(arguments) | - |
| 2627 | { | - |
| 2628 | } executed: }Execution Count:63 | 63 |
| 2629 | | - |
| 2630 | /*! | - |
| 2631 | Destroys this SignalEvent. | - |
| 2632 | */ | - |
| 2633 | QStateMachine::SignalEvent::~SignalEvent() | - |
| 2634 | { | - |
| 2635 | } | - |
| 2636 | | - |
| 2637 | /*! | - |
| 2638 | \fn QStateMachine::SignalEvent::sender() const | - |
| 2639 | | - |
| 2640 | Returns the object that emitted the signal. | - |
| 2641 | | - |
| 2642 | \sa QObject::sender() | - |
| 2643 | */ | - |
| 2644 | | - |
| 2645 | /*! | - |
| 2646 | \fn QStateMachine::SignalEvent::signalIndex() const | - |
| 2647 | | - |
| 2648 | Returns the index of the signal. | - |
| 2649 | | - |
| 2650 | \sa QMetaObject::indexOfSignal(), QMetaObject::method() | - |
| 2651 | */ | - |
| 2652 | | - |
| 2653 | /*! | - |
| 2654 | \fn QStateMachine::SignalEvent::arguments() const | - |
| 2655 | | - |
| 2656 | Returns the arguments of the signal. | - |
| 2657 | */ | - |
| 2658 | | - |
| 2659 | | - |
| 2660 | /*! | - |
| 2661 | \class QStateMachine::WrappedEvent | - |
| 2662 | \inmodule QtCore | - |
| 2663 | | - |
| 2664 | \brief The WrappedEvent class inherits QEvent and holds a clone of an event associated with a QObject. | - |
| 2665 | | - |
| 2666 | \since 4.6 | - |
| 2667 | \ingroup statemachine | - |
| 2668 | | - |
| 2669 | A wrapped event is generated by a QStateMachine in response to a Qt | - |
| 2670 | event. The QEventTransition class provides a transition associated with a | - |
| 2671 | such an event. QStateMachine::WrappedEvent is part of \l{The State Machine | - |
| 2672 | Framework}. | - |
| 2673 | | - |
| 2674 | The object() function returns the object that generated the event. The | - |
| 2675 | event() function returns a clone of the original event. | - |
| 2676 | | - |
| 2677 | \sa QEventTransition | - |
| 2678 | */ | - |
| 2679 | | - |
| 2680 | /*! | - |
| 2681 | \internal | - |
| 2682 | | - |
| 2683 | Constructs a new WrappedEvent object with the given \a object | - |
| 2684 | and \a event. | - |
| 2685 | | - |
| 2686 | The WrappedEvent object takes ownership of \a event. | - |
| 2687 | */ | - |
| 2688 | QStateMachine::WrappedEvent::WrappedEvent(QObject *object, QEvent *event) | - |
| 2689 | : QEvent(QEvent::StateMachineWrapped), m_object(object), m_event(event) | - |
| 2690 | { | - |
| 2691 | } executed: }Execution Count:26 | 26 |
| 2692 | | - |
| 2693 | /*! | - |
| 2694 | Destroys this WrappedEvent. | - |
| 2695 | */ | - |
| 2696 | QStateMachine::WrappedEvent::~WrappedEvent() | - |
| 2697 | { | - |
| 2698 | delete m_event; executed (the execution status of this line is deduced): delete m_event; | - |
| 2699 | } executed: }Execution Count:25 | 25 |
| 2700 | | - |
| 2701 | /*! | - |
| 2702 | \fn QStateMachine::WrappedEvent::object() const | - |
| 2703 | | - |
| 2704 | Returns the object that the event is associated with. | - |
| 2705 | */ | - |
| 2706 | | - |
| 2707 | /*! | - |
| 2708 | \fn QStateMachine::WrappedEvent::event() const | - |
| 2709 | | - |
| 2710 | Returns a clone of the original event. | - |
| 2711 | */ | - |
| 2712 | | - |
| 2713 | QT_END_NAMESPACE | - |
| 2714 | | - |
| 2715 | #include "qstatemachine.moc" | - |
| 2716 | #include "moc_qstatemachine.cpp" | - |
| 2717 | | - |
| 2718 | #endif //QT_NO_STATEMACHINE | - |
| 2719 | | - |
| | |