diff --git a/indra/newview/statemachine/aistatemachine.cpp b/indra/newview/statemachine/aistatemachine.cpp index db181ce45..94cb9da59 100644 --- a/indra/newview/statemachine/aistatemachine.cpp +++ b/indra/newview/statemachine/aistatemachine.cpp @@ -603,7 +603,7 @@ void AIStateMachine::flush(void) for (active_statemachines_type::iterator iter = active_statemachines.begin(); iter != active_statemachines.end(); ++iter) { AIStateMachine& statemachine(iter->statemachine()); - if (statemachine.running()) + if (statemachine.abortable()) statemachine.abort(); } for (int batch = 0;; ++batch) diff --git a/indra/newview/statemachine/aistatemachine.h b/indra/newview/statemachine/aistatemachine.h index 650e7f296..237c466ea 100644 --- a/indra/newview/statemachine/aistatemachine.h +++ b/indra/newview/statemachine/aistatemachine.h @@ -350,6 +350,9 @@ class AIStateMachine { //! Return true if the derived class is running (also when we are idle). bool running(void) const { return mState == bs_run; } + //! Return true if it's safe to call abort. + bool abortable(void) const { return (mState == bs_run && (!mIdle || is_main_thread())) || mState == bs_initialize; } + //! Return true if the derived class is running but idle. bool waiting(void) const { return mState == bs_run && mIdle; }