diff options
Diffstat (limited to 'src/corelib/statemachine/qstate.cpp')
-rw-r--r-- | src/corelib/statemachine/qstate.cpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp index 9abf20b..5dc310b 100644 --- a/src/corelib/statemachine/qstate.cpp +++ b/src/corelib/statemachine/qstate.cpp @@ -124,8 +124,9 @@ QT_BEGIN_NAMESPACE */ QStatePrivate::QStatePrivate() - : errorState(0), initialState(0), childMode(QState::ExclusiveStates), - transitionsListNeedsRefresh(true) + : QAbstractStatePrivate(StandardState), + errorState(0), initialState(0), childMode(QState::ExclusiveStates), + childStatesListNeedsRefresh(true), transitionsListNeedsRefresh(true) { } @@ -181,15 +182,18 @@ QState::~QState() QList<QAbstractState*> QStatePrivate::childStates() const { - QList<QAbstractState*> result; - QList<QObject*>::const_iterator it; - for (it = children.constBegin(); it != children.constEnd(); ++it) { - QAbstractState *s = qobject_cast<QAbstractState*>(*it); - if (!s || qobject_cast<QHistoryState*>(s)) - continue; - result.append(s); + if (childStatesListNeedsRefresh) { + childStatesList.clear(); + QList<QObject*>::const_iterator it; + for (it = children.constBegin(); it != children.constEnd(); ++it) { + QAbstractState *s = qobject_cast<QAbstractState*>(*it); + if (!s || qobject_cast<QHistoryState*>(s)) + continue; + childStatesList.append(s); + } + childStatesListNeedsRefresh = false; } - return result; + return childStatesList; } QList<QHistoryState*> QStatePrivate::historyStates() const @@ -473,8 +477,10 @@ void QState::setChildMode(ChildMode mode) bool QState::event(QEvent *e) { Q_D(QState); - if ((e->type() == QEvent::ChildAdded) || (e->type() == QEvent::ChildRemoved)) + if ((e->type() == QEvent::ChildAdded) || (e->type() == QEvent::ChildRemoved)) { + d->childStatesListNeedsRefresh = true; d->transitionsListNeedsRefresh = true; + } return QAbstractState::event(e); } |