From af4ceb06580d6c16a8d90056b0e35f39b98c761c Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Fri, 3 Aug 2012 00:53:54 +0200 Subject: [PATCH] Crash on exit fix. --- indra/newview/statemachine/aistatemachine.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/indra/newview/statemachine/aistatemachine.cpp b/indra/newview/statemachine/aistatemachine.cpp index 71a8ac47f..675317cb1 100644 --- a/indra/newview/statemachine/aistatemachine.cpp +++ b/indra/newview/statemachine/aistatemachine.cpp @@ -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(;;) { {