summaryrefslogtreecommitdiffstats
path: root/src/corelib/statemachine
diff options
context:
space:
mode:
authorAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-04-13 14:45:11 +0300
committerAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-04-18 04:49:19 +0000
commitf083830b8de106ed51d39242008215e9ea2179b2 (patch)
treeee0be5ed145cacd93cdda159e31ea47ebbebede9 /src/corelib/statemachine
parent777d46b40360c302a49fc5b789cee6d0d05f840a (diff)
CoreLib: use const (and const APIs) more
For CoW types const methods will be called. Mark store_persistent_indexes() as const, because this method does not modify the object. Change-Id: Ic867913b4fb5aaebfbaaffe1d3be45cf7b646403 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/statemachine')
-rw-r--r--src/corelib/statemachine/qhistorystate.cpp9
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp2
2 files changed, 7 insertions, 4 deletions
diff --git a/src/corelib/statemachine/qhistorystate.cpp b/src/corelib/statemachine/qhistorystate.cpp
index c3361ad17e..338c89c688 100644
--- a/src/corelib/statemachine/qhistorystate.cpp
+++ b/src/corelib/statemachine/qhistorystate.cpp
@@ -209,6 +209,11 @@ QAbstractState *QHistoryState::defaultState() const
return d->defaultTransition ? d->defaultTransition->targetState() : Q_NULLPTR;
}
+static inline bool isSoleEntry(const QList<QAbstractState*> &states, const QAbstractState * state)
+{
+ return states.size() == 1 && states.first() == state;
+}
+
/*!
Sets this history state's default state to be the given \a state.
\a state must be a sibling of this history state.
@@ -224,9 +229,7 @@ void QHistoryState::setDefaultState(QAbstractState *state)
"to this history state's group (%p)", state, parentState());
return;
}
- if (!d->defaultTransition
- || d->defaultTransition->targetStates().size() != 1
- || d->defaultTransition->targetStates().first() != state) {
+ if (!d->defaultTransition || !isSoleEntry(d->defaultTransition->targetStates(), state)) {
if (!d->defaultTransition || !qobject_cast<DefaultStateTransition*>(d->defaultTransition)) {
d->defaultTransition = new DefaultStateTransition(this, state);
emit defaultTransitionChanged(QHistoryState::QPrivateSignal());
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index 62a4c03d26..d5b01f3c8a 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -692,7 +692,7 @@ void QStateMachinePrivate::microstep(QEvent *event, const QList<QAbstractTransit
// Add "implicit" assignments for restored properties to the first
// (outermost) entered state
Q_ASSERT(!enteredStates.isEmpty());
- QAbstractState *s = enteredStates.first();
+ QAbstractState *s = enteredStates.constFirst();
assignmentsForEnteredStates[s] << restorablesToPropertyList(pendingRestorables);
}