1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-01-18 19:47:15 +01:00

Move the resource releasing from the global event type to it's destructor.

This commit is contained in:
Sandu Liviu Catalin 2015-10-31 21:27:21 +02:00
parent d937be3e37
commit ab78f53875
2 changed files with 9 additions and 22 deletions

View File

@ -50,8 +50,6 @@ GlobalEvent::GlobalEvent(SQInt32 type, bool suspended) noexcept
{ {
// Attach to the specified event signal // Attach to the specified event signal
Attach(); Attach();
// Receive notification when the VM is about to be closed to release object references
_Core->VMClose.Connect< GlobalEvent, &GlobalEvent::VMClose >(this);
/* Entity filters are empty so there's nothing to hook to! */ /* Entity filters are empty so there's nothing to hook to! */
} }
@ -60,9 +58,16 @@ GlobalEvent::~GlobalEvent()
{ {
// Detach from the specified event signal // Detach from the specified event signal
Detach(); Detach();
// Stop receiving notification when the VM is about to be closed
_Core->VMClose.Disconnect< GlobalEvent, &GlobalEvent::VMClose >(this);
/* We're expecting the entity filters to unhook themselves from the destroy signal! */ /* We're expecting the entity filters to unhook themselves from the destroy signal! */
// Release the reference to the specified callbacks
m_OnTrigger.Release2();
m_OnInclude.Release2();
m_OnExclude.Release2();
m_OnCleared.Release2();
m_OnRelease.Release2();
// Release the reference to the specified user data
m_Data.Release();
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -2063,19 +2068,6 @@ void GlobalEvent::Adaptable(SQInt32 type) noexcept
} }
} }
// ------------------------------------------------------------------------------------------------
void GlobalEvent::VMClose() noexcept
{
// Release the reference to the specified callbacks
m_OnTrigger.Release2();
m_OnInclude.Release2();
m_OnExclude.Release2();
m_OnCleared.Release2();
m_OnRelease.Release2();
// Release the reference to the specified user data
m_Data.Release();
}
// ================================================================================================ // ================================================================================================
template < class T > static bool Register_GlobalFilter(HSQUIRRELVM vm, const SQChar * cname) template < class T > static bool Register_GlobalFilter(HSQUIRRELVM vm, const SQChar * cname)
{ {

View File

@ -1005,11 +1005,6 @@ public:
*/ */
void SphereExited(SQInt32 player, SQInt32 sphere) noexcept; void SphereExited(SQInt32 player, SQInt32 sphere) noexcept;
/* --------------------------------------------------------------------------------------------
* ...
*/
void VMClose() noexcept;
protected: protected:
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------