summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-05-04 13:44:39 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-05-04 13:45:58 (GMT)
commite2cb1fe3f71a0fd74c49af2fc451a1e05ed2742b (patch)
tree898ab6d109cb3afe6e035e13152f89d926a97367
parent1e4e05144dd8a0c642b6a7f77aa53fa6975d89d9 (diff)
downloadQt-e2cb1fe3f71a0fd74c49af2fc451a1e05ed2742b.zip
Qt-e2cb1fe3f71a0fd74c49af2fc451a1e05ed2742b.tar.gz
Qt-e2cb1fe3f71a0fd74c49af2fc451a1e05ed2742b.tar.bz2
ignore QState::assignProperty() calls where the target object is 0
-rw-r--r--src/corelib/statemachine/qstate.cpp4
-rw-r--r--tests/auto/qstatemachine/tst_qstatemachine.cpp4
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);