1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-01-19 12:07:13 +01:00

Properly terminate all command controllers and release their resources and callbacks to prevent a server crash at shutdown since callbacks were not released.

This commit is contained in:
Sandu Liviu Catalin 2016-07-14 21:29:04 +03:00
parent c854700cac
commit 498c02fa83
2 changed files with 7 additions and 3 deletions

View File

@ -1193,7 +1193,7 @@ void Register_Command(HSQUIRRELVM vm)
*/ */
void TerminateCommands() void TerminateCommands()
{ {
Cmd::Controller::ClearAll(); Cmd::Controller::Terminate();
} }
} // Namespace:: SqMod } // Namespace:: SqMod

View File

@ -504,13 +504,17 @@ protected:
public: 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) for (auto & ctr : s_Controllers)
{ {
// Clear the command listeners
ctr->Clear(); ctr->Clear();
// Release the script callbacks, if any
ctr->m_OnFail.ReleaseGently();
ctr->m_OnAuth.ReleaseGently();
} }
} }