mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2026-09-07 07:27:12 +02:00
Implement a new module command that is called right before cosing the virtual machine to allow modules to release resources manually.
Should fix a possible crash in the IRC plugin which was caused by the Session destructor to be called recursively when cleaned automatically by the VM.
This commit is contained in:
+13
-2
@@ -99,6 +99,15 @@ static void OnSquirrelTerminate()
|
||||
NullFunction().ReleaseGently();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* The virtual machined is about to be closed. Last chance to release anything manually.
|
||||
*/
|
||||
static void OnSquirrelClosing()
|
||||
{
|
||||
// Terminate all sessions, if any
|
||||
SessionTerminate();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* The virtual machined was closed and all memory associated with it was released.
|
||||
*/
|
||||
@@ -106,8 +115,6 @@ static void OnSquirrelReleased()
|
||||
{
|
||||
// Release the current virtual machine, if any
|
||||
DefaultVM::Set(nullptr);
|
||||
// Terminate all sessions, if any
|
||||
SessionTerminate();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
@@ -141,6 +148,10 @@ static uint8_t OnPluginCommand(uint32_t command_identifier, CCStr message)
|
||||
{
|
||||
OnSquirrelTerminate();
|
||||
} break;
|
||||
case SQMOD_CLOSING_CMD:
|
||||
{
|
||||
OnSquirrelClosing();
|
||||
} break;
|
||||
case SQMOD_RELEASED_CMD:
|
||||
{
|
||||
OnSquirrelReleased();
|
||||
|
||||
Reference in New Issue
Block a user