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>
This commit is contained in:
parent
aabf4e4f04
commit
ff11568f37
|
@ -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()) {
|
||||
|
|
Loading…
Reference in New Issue