diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2012-05-31 12:17:02 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-04 16:50:24 +0200 |
commit | 268216570881cfc7d066d8183047d05829e1248b (patch) | |
tree | 3f5fd5b80a0d25fa7ebbfb1e72a1bfea9c3ffc74 /src/corelib | |
parent | 939aa5113859768f058ed663a10e26f82a5db287 (diff) |
Fix typos in QState sorting functions
A QObject can't be a child of itself, so the comparison always
returned false. In practice, this was causing the entry/exit order
of parallel states to be random.
QObject::children() is documented to contain the children in the
order in which they were added, so this fix actually achieves
deterministic behavior.
Task-number: QTBUG-25959
Change-Id: Id3f12d6bfbc249f1d4fed0bafb7d0217093e458e
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/statemachine/qstatemachine.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index 21c3ab50b5..fd190abc01 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -252,8 +252,8 @@ static int indexOfDescendant(QState *s, QAbstractState *desc) bool QStateMachinePrivate::stateEntryLessThan(QAbstractState *s1, QAbstractState *s2) { if (s1->parent() == s2->parent()) { - return s1->children().indexOf(s1) - < s2->children().indexOf(s2); + return s1->parent()->children().indexOf(s1) + < s2->parent()->children().indexOf(s2); } else if (isDescendantOf(s1, s2)) { return false; } else if (isDescendantOf(s2, s1)) { @@ -270,8 +270,8 @@ bool QStateMachinePrivate::stateEntryLessThan(QAbstractState *s1, QAbstractState bool QStateMachinePrivate::stateExitLessThan(QAbstractState *s1, QAbstractState *s2) { if (s1->parent() == s2->parent()) { - return s1->children().indexOf(s1) - < s2->children().indexOf(s2); + return s1->parent()->children().indexOf(s1) + < s2->parent()->children().indexOf(s2); } else if (isDescendantOf(s1, s2)) { return true; } else if (isDescendantOf(s2, s1)) { |