diff --git a/source/Command.cpp b/source/Command.cpp index 54ad3ed8..6c1a9908 100644 --- a/source/Command.cpp +++ b/source/Command.cpp @@ -1193,7 +1193,7 @@ void Register_Command(HSQUIRRELVM vm) */ void TerminateCommands() { - Cmd::Controller::ClearAll(); + Cmd::Controller::Terminate(); } } // Namespace:: SqMod diff --git a/source/Command.hpp b/source/Command.hpp index 19b5327a..65345538 100644 --- a/source/Command.hpp +++ b/source/Command.hpp @@ -504,13 +504,17 @@ protected: public: /* -------------------------------------------------------------------------------------------- - * Clear the command listeners from all controllers. + * Terminate the all controllers by releasing their command listeners and callbacks. */ - static void ClearAll() + static void Terminate() { for (auto & ctr : s_Controllers) { + // Clear the command listeners ctr->Clear(); + // Release the script callbacks, if any + ctr->m_OnFail.ReleaseGently(); + ctr->m_OnAuth.ReleaseGently(); } }