mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-06-30 22:17:13 +02:00
Prevent the command destructor from dissociating the listener from the manager in destructor when the container was resized.
This commit is contained in:
@ -39,6 +39,55 @@ Guard::~Guard()
|
||||
mController->m_Context = mPrevious;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Command::Command(std::size_t hash, const String & name, Listener * ptr, const CtrPtr & ctr)
|
||||
: mHash(hash), mName(name), mPtr(ptr), mObj(ptr), mCtr(ctr)
|
||||
{
|
||||
if (mPtr)
|
||||
{
|
||||
mPtr->m_Controller = mCtr; // Create controller association
|
||||
}
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Command::Command(std::size_t hash, const String & name, const Object & obj, const CtrPtr & ctr)
|
||||
: mHash(hash), mName(name), mPtr(obj.Cast< Listener * >()), mObj(obj), mCtr(ctr)
|
||||
{
|
||||
if (mPtr)
|
||||
{
|
||||
mPtr->m_Controller = mCtr; // Create controller association
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Command::Command(std::size_t hash, const String & name, Object && obj, const CtrPtr & ctr)
|
||||
: mHash(hash), mName(name), mPtr(obj.Cast< Listener * >()), mObj(obj), mCtr(ctr)
|
||||
{
|
||||
if (mPtr)
|
||||
{
|
||||
mPtr->m_Controller = mCtr; // Create controller association
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Command::Command(std::size_t hash, const String & name, Listener * ptr, const Object & obj, const CtrPtr & ctr)
|
||||
: mHash(hash), mName(name), mPtr(ptr), mObj(obj), mCtr(ctr)
|
||||
{
|
||||
if (mPtr)
|
||||
{
|
||||
mPtr->m_Controller = mCtr; // Create controller association
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Command::Command(std::size_t hash, const String & name, Listener * ptr, Object && obj, const CtrPtr & ctr)
|
||||
: mHash(hash), mName(name), mPtr(ptr), mObj(obj), mCtr(ctr)
|
||||
{
|
||||
if (mPtr)
|
||||
{
|
||||
mPtr->m_Controller = mCtr; // Create controller association
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Command::~Command()
|
||||
{
|
||||
@ -102,12 +151,7 @@ Object & Controller::Attach(Object && obj, Listener * ptr)
|
||||
}
|
||||
}
|
||||
// Attempt to insert the command
|
||||
m_Commands.emplace_back(hash, name, ptr, std::move(obj));
|
||||
// Attempt to associate with the listener
|
||||
if (m_Manager)
|
||||
{
|
||||
ptr->m_Controller = m_Manager->GetCtr();
|
||||
}
|
||||
m_Commands.emplace_back(hash, name, ptr, std::move(obj), m_Manager->GetCtr());
|
||||
// Return the script object of the listener
|
||||
return m_Commands.back().mObj;
|
||||
}
|
||||
|
Reference in New Issue
Block a user