(EntityHandle) Fixed swap
Former-commit-id: 735dd9d2c3080d202306ef9cfb1bb130639e93cd
This commit is contained in:
parent
0d8f7546a9
commit
c818ef7d4b
|
|
@ -68,6 +68,22 @@ namespace Ndk
|
||||||
|
|
||||||
inline EntityHandle& EntityHandle::Swap(EntityHandle& handle)
|
inline EntityHandle& EntityHandle::Swap(EntityHandle& handle)
|
||||||
{
|
{
|
||||||
|
// Comme nous inversons les handles, nous devons prévenir les entités
|
||||||
|
// La version par défaut de swap (à base de move) aurait fonctionné,
|
||||||
|
// mais en enregistrant les handles une fois de plus que nécessaire (à cause de la copie temporaire).
|
||||||
|
if (m_entity)
|
||||||
|
{
|
||||||
|
m_entity->UnregisterHandle(this);
|
||||||
|
m_entity->RegisterHandle(&handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handle.m_entity)
|
||||||
|
{
|
||||||
|
handle.m_entity->UnregisterHandle(&handle);
|
||||||
|
handle.m_entity->RegisterHandle(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// On effectue l'échange
|
||||||
std::swap(m_entity, handle.m_entity);
|
std::swap(m_entity, handle.m_entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue