Crash on exit fix.

This commit is contained in:
Aleric Inglewood
2012-08-03 00:53:54 +02:00
parent 464919072d
commit af4ceb0658

View File

@@ -610,11 +610,19 @@ void AIStateMachine::flush(void)
{
AIStateMachine& statemachine(iter->statemachine());
if (statemachine.abortable())
statemachine.abort();
{
// We can't safely call abort() here for non-running (run() was called, but they we're initialized yet) statemachines,
// because that might call kill() which in some cases is undesirable (ie, when it is owned by a partent that will
// also call abort() on it when it is aborted itself).
if (statemachine.running())
statemachine.abort();
else
statemachine.idle(); // Stop the statemachine from starting, in the next loop with batch == 0.
}
}
for (int batch = 0;; ++batch)
{
// Run mainloop until all state machines are idle.
// Run mainloop until all state machines are idle (batch == 0) or deleted (batch == 1).
for(;;)
{
{