diff options
author | Albert Astals Cid <albert.astals.cid@kdab.com> | 2018-10-19 16:41:57 +0200 |
---|---|---|
committer | Albert Astals Cid <albert.astals.cid@kdab.com> | 2018-10-23 10:52:17 +0000 |
commit | ff11568f37999c62e7683b1c21861be63f14567c (patch) | |
tree | bfe0a1bbcdaf423abb96998256b38b89b0f213db /src/quick/util | |
parent | aabf4e4f0474d8d6eb065fbab700432718070ae0 (diff) |
QQuickStateGroup: Warn if two states have the same name
Otherwise it is silently ignored and given that we change
states by name i think it's a thing the user would want
to know that he made such a mistake, i know i would
since i just lost some time figuring out why changes i made
to a state didn't apply and it was because i had a duplicate
state name in a long states definition
Change-Id: I342e44829f7d32daf6eed0edad33f5b7a42ff5bf
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/quick/util')
-rw-r--r-- | src/quick/util/qquickstategroup.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/quick/util/qquickstategroup.cpp b/src/quick/util/qquickstategroup.cpp index c852c16509..3d8c5e0507 100644 --- a/src/quick/util/qquickstategroup.cpp +++ b/src/quick/util/qquickstategroup.cpp @@ -302,10 +302,18 @@ void QQuickStateGroup::componentComplete() Q_D(QQuickStateGroup); d->componentComplete = true; + QSet<QString> names; for (int ii = 0; ii < d->states.count(); ++ii) { QQuickState *state = d->states.at(ii); if (!state->isNamed()) state->setName(QLatin1String("anonymousState") + QString::number(++d->unnamedCount)); + + const QString stateName = state->name(); + if (names.contains(stateName)) { + qmlWarning(state->parent()) << "Found duplicate state name: " << stateName; + } else { + names << stateName; + } } if (d->updateAutoState()) { |