path: root/src/corelib/statemachine
diff options
authorMarc Mutz <>2015-01-08 14:52:01 +0100
committerMarc Mutz <>2015-01-09 12:06:15 +0100
commit65eb57392685d69313217fd17e06376db8f9c05b (patch)
treeabdf5ee302138a0abd26f1ac5579ebfbfb1f9f05 /src/corelib/statemachine
parent3ecc44d5d26de661eaaaf4164092b2941f5dd615 (diff)
QStateMachine: fix some misleading code
The old code creates a RestorableId from the passed (QObject*, QByteArray) and used it for lookup in a hash table (ok) and as a container for the (QObject*, QByteArray), satisfying later references to those parameters from the RestorableId instance instead of using the parameters directly. Now, RestorableId holds the QObject* in a QPointer, so the code might have wanted to detect the object being destroyed as part of the operation, BUT: a) the operation is a read-only one, and b) the code didn't check for nullness before dereferencing the QObject*. Fix by moving the creation of the RestorableId into the scope it's used and otherwise using the parameters directly. Change-Id: Iaf12f722fe6841ee1a55037fe33a6115aa699aca Reviewed-by: Thiago Macieira <>
Diffstat (limited to 'src/corelib/statemachine')
1 files changed, 2 insertions, 3 deletions
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index 69e942d4fd..27c7b077c6 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -882,11 +882,10 @@ QVariant QStateMachinePrivate::savedValueForRestorable(const QList<QAbstractStat
qDebug() << q_func() << ": savedValueForRestorable(" << exitedStates_sorted << object << propertyName << ")";
- RestorableId id(object, propertyName);
for (int i = exitedStates_sorted.size() - 1; i >= 0; --i) {
QAbstractState *s =;
QHash<RestorableId, QVariant> restorables = registeredRestorablesForState.value(s);
- QHash<RestorableId, QVariant>::const_iterator it = restorables.constFind(id);
+ QHash<RestorableId, QVariant>::const_iterator it = restorables.constFind(RestorableId(object, propertyName));
if (it != restorables.constEnd()) {
qDebug() << q_func() << ": using" << it.value() << "from" << s;
@@ -897,7 +896,7 @@ QVariant QStateMachinePrivate::savedValueForRestorable(const QList<QAbstractStat
qDebug() << q_func() << ": falling back to current value";
- return id.first->property(id.second);
+ return object->property(propertyName);
void QStateMachinePrivate::registerRestorable(QAbstractState *state, QObject *object, const QByteArray &propertyName,