From fa99a2ab12f646d73498b69fae0020da1abf9685 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 14 May 2009 10:59:00 +0200 Subject: Fix run-time error in Seek AI's state machine Passed parent as 'tank', thus getting a null parent in the GoToLocation state, which breaks the machine when you transition into the state. --- examples/statemachine/tankgameplugins/seek_ai/seek_ai.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'examples/statemachine') diff --git a/examples/statemachine/tankgameplugins/seek_ai/seek_ai.h b/examples/statemachine/tankgameplugins/seek_ai/seek_ai.h index 2835988799..597f859581 100644 --- a/examples/statemachine/tankgameplugins/seek_ai/seek_ai.h +++ b/examples/statemachine/tankgameplugins/seek_ai/seek_ai.h @@ -137,16 +137,20 @@ public: ChaseState(QObject *tank, QState *parentState = 0) : QState(parentState), m_tank(tank) { QState *fireCannon = new QState(this); + fireCannon->setObjectName("fireCannon"); connect(fireCannon, SIGNAL(entered()), tank, SLOT(fireCannon())); setInitialState(fireCannon); - m_goToLocation = new GoToLocationState(this); + m_goToLocation = new GoToLocationState(tank, this); + m_goToLocation->setObjectName("goToLocation"); fireCannon->addTransition(tank, SIGNAL(actionCompleted()), m_goToLocation); m_turnToDirection = new QState(this); + m_turnToDirection->setObjectName("turnToDirection"); m_goToLocation->addTransition(tank, SIGNAL(actionCompleted()), m_turnToDirection); QFinalState *finalState = new QFinalState(this); + finalState->setObjectName("finalState"); m_turnToDirection->addTransition(tank, SIGNAL(actionCompleted()), finalState); } -- cgit v1.2.1