summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-05-05 12:54:04 (GMT)
committerEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-05-05 12:54:04 (GMT)
commitef2c9e7e6ea543a7ca1ee23b5bbaa9dee5f77b8a (patch)
treed6a786fbe8ba917e247783c7299356c93f244d12 /examples
parent6de0b13042f39b7570588eb5615cc1e16a71eced (diff)
downloadQt-ef2c9e7e6ea543a7ca1ee23b5bbaa9dee5f77b8a.zip
Qt-ef2c9e7e6ea543a7ca1ee23b5bbaa9dee5f77b8a.tar.gz
Qt-ef2c9e7e6ea543a7ca1ee23b5bbaa9dee5f77b8a.tar.bz2
Make sure target state is set correctly. Also make sure eventTest() actually
overrides the virtual function.
Diffstat (limited to 'examples')
-rw-r--r--examples/statemachine/errorstateplugins/seek_ai/seek_ai.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/examples/statemachine/errorstateplugins/seek_ai/seek_ai.h b/examples/statemachine/errorstateplugins/seek_ai/seek_ai.h
index f96a68f..7f108a1 100644
--- a/examples/statemachine/errorstateplugins/seek_ai/seek_ai.h
+++ b/examples/statemachine/errorstateplugins/seek_ai/seek_ai.h
@@ -8,6 +8,7 @@
#include <QSignalEvent>
#include <QVariant>
#include <QLineF>
+#include <QDebug>
class SearchState: public QState
{
@@ -75,14 +76,16 @@ public:
m_tank(tank),
m_turnTo(turnTo)
{
+ setTargetState(turnTo);
}
protected:
- bool eventTest(QEvent *event)
+ bool eventTest(QEvent *event) const
{
- QSignalEvent *se = static_cast<QSignalEvent *>(event);
- m_lastLine = se->arguments().at(0).toLineF();
-
+ if (event->type() == QEvent::Signal) {
+ QSignalEvent *se = static_cast<QSignalEvent *>(event);
+ m_lastLine = se->arguments().at(0).toLineF();
+ }
return QSignalTransition::eventTest(event);
}
@@ -101,7 +104,7 @@ protected:
}
private:
- QLineF m_lastLine;
+ mutable QLineF m_lastLine;
QObject *m_tank;
QState *m_turnTo;
};