statemachine: Tiny refactoring to avoid double lookup
Change-Id: I5040ca417dc12e1e0938ba7669b3017e414d13f9 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
This commit is contained in:
parent
130830e2d3
commit
d2a6f8e6dd
@ -242,7 +242,7 @@ void QState::assignProperty(QObject *object, const char *name,
|
|||||||
}
|
}
|
||||||
for (int i = 0; i < d->propertyAssignments.size(); ++i) {
|
for (int i = 0; i < d->propertyAssignments.size(); ++i) {
|
||||||
QPropertyAssignment &assn = d->propertyAssignments[i];
|
QPropertyAssignment &assn = d->propertyAssignments[i];
|
||||||
if ((assn.object == object) && (assn.propertyName == name)) {
|
if (assn.hasTarget(object, name)) {
|
||||||
assn.value = value;
|
assn.value = value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,8 @@ struct QPropertyAssignment
|
|||||||
|
|
||||||
bool objectDeleted() const { return !object; }
|
bool objectDeleted() const { return !object; }
|
||||||
void write() const { Q_ASSERT(object != 0); object->setProperty(propertyName, value); }
|
void write() const { Q_ASSERT(object != 0); object->setProperty(propertyName, value); }
|
||||||
|
bool hasTarget(QObject *o, const QByteArray &pn) const
|
||||||
|
{ return object == o && propertyName == pn; }
|
||||||
|
|
||||||
QPointer<QObject> object;
|
QPointer<QObject> object;
|
||||||
QByteArray propertyName;
|
QByteArray propertyName;
|
||||||
|
@ -743,8 +743,7 @@ void QStateMachinePrivate::applyProperties(const QList<QAbstractTransition*> &tr
|
|||||||
for (it = propertyAssignmentsForState.constBegin(); it != propertyAssignmentsForState.constEnd(); ++it) {
|
for (it = propertyAssignmentsForState.constBegin(); it != propertyAssignmentsForState.constEnd(); ++it) {
|
||||||
const QList<QPropertyAssignment> &assignments = it.value();
|
const QList<QPropertyAssignment> &assignments = it.value();
|
||||||
for (int k = 0; k < assignments.size(); ++k) {
|
for (int k = 0; k < assignments.size(); ++k) {
|
||||||
if ((assignments.at(k).object == assn.object)
|
if (assignments.at(k).hasTarget(assn.object, assn.propertyName)) {
|
||||||
&& (assignments.at(k).propertyName == assn.propertyName)) {
|
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user