diff options
-rw-r--r-- | src/corelib/statemachine/qstate.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qstatemachine/tst_qstatemachine.cpp | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp index 2d59ab8..a431888 100644 --- a/src/corelib/statemachine/qstate.cpp +++ b/src/corelib/statemachine/qstate.cpp @@ -235,6 +235,10 @@ void QState::assignProperty(QObject *object, const char *name, const QVariant &value) { Q_D(QState); + if (!object) { + qWarning("QState::assignProperty: cannot assign property '%s' of null object", name); + return; + } for (int i = 0; i < d->propertyAssignments.size(); ++i) { QPropertyAssignment &assn = d->propertyAssignments[i]; if ((assn.object == object) && (assn.propertyName == name)) { diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index 80bf674..5dfc758 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -1194,6 +1194,10 @@ void tst_QStateMachine::assignProperty() { QStateMachine machine; QState *s1 = new QState(machine.rootState()); + + QTest::ignoreMessage(QtWarningMsg, "QState::assignProperty: cannot assign property 'foo' of null object"); + s1->assignProperty(0, "foo", QVariant()); + s1->assignProperty(s1, "objectName", "s1"); QFinalState *s2 = new QFinalState(machine.rootState()); s1->addTransition(s2); |