diff --git a/indra/aistatemachine/aistatemachine.h b/indra/aistatemachine/aistatemachine.h index dffd93c7d..10031a834 100644 --- a/indra/aistatemachine/aistatemachine.h +++ b/indra/aistatemachine/aistatemachine.h @@ -296,7 +296,7 @@ class AIStateMachine : public LLThreadSafeRefCount return false; else if (mSleep < 0) ++mSleep; - else if ((U64)mSleep >= current_time) + else if ((U64)mSleep <= current_time) mSleep = 0; return mSleep != 0; } diff --git a/indra/newview/statemachine/aifilepicker.cpp b/indra/newview/statemachine/aifilepicker.cpp index c3675c4e1..418d83955 100644 --- a/indra/newview/statemachine/aifilepicker.cpp +++ b/indra/newview/statemachine/aifilepicker.cpp @@ -46,14 +46,6 @@ #include "llwindowsdl.h" #endif - -enum filepicker_state_type { - AIFilePicker_initialize_plugin = AIStateMachine::max_state, - AIFilePicker_plugin_running, - AIFilePicker_canceled, - AIFilePicker_done -}; - char const* AIFilePicker::state_str_impl(state_type run_state) const { switch(run_state) @@ -63,6 +55,7 @@ char const* AIFilePicker::state_str_impl(state_type run_state) const AI_CASE_RETURN(AIFilePicker_canceled); AI_CASE_RETURN(AIFilePicker_done); } + llassert(false); return "UNKNOWN STATE"; } @@ -361,6 +354,7 @@ void AIFilePicker::multiplex_impl(state_type run_state) { if (!plugin->isPluginRunning()) { + yield(); break; // Still initializing. } @@ -457,7 +451,7 @@ void AIFilePicker::receivePluginMessage(const LLPluginMessage &message) if (message_name == "canceled") { LL_DEBUGS("Plugin") << "received message \"canceled\"" << LL_ENDL; - advance_state(AIFilePicker_canceled); + set_state(AIFilePicker_canceled); } else if (message_name == "done") { @@ -468,7 +462,7 @@ void AIFilePicker::receivePluginMessage(const LLPluginMessage &message) { mFilenames.push_back(*filename); } - advance_state(AIFilePicker_done); + set_state(AIFilePicker_done); } else { diff --git a/indra/newview/statemachine/aifilepicker.h b/indra/newview/statemachine/aifilepicker.h index a5ee00a61..0058ea2f0 100644 --- a/indra/newview/statemachine/aifilepicker.h +++ b/indra/newview/statemachine/aifilepicker.h @@ -151,7 +151,21 @@ new AIFilePicker // Objects of this type can be reused multiple times, see // also the documentation of AIStateMachine. class AIFilePicker : public AIStateMachine { +protected: + // The base class of this state machine. + typedef AIStateMachine direct_base_type; + + enum filepicker_state_type { + AIFilePicker_initialize_plugin = direct_base_type::max_state, + AIFilePicker_plugin_running, + AIFilePicker_canceled, + AIFilePicker_done + }; public: + static state_type const max_state = AIFilePicker_done + 1; // One beyond the largest state. + +public: + // The derived class must have a default constructor. AIFilePicker(void); // Create a dynamically created AIFilePicker object.