Sdk/EntityOwner: Fix move assignement operator

This commit is contained in:
Lynix 2018-04-24 21:55:55 +02:00
parent 97067cb566
commit 4a6d9dba51
3 changed files with 16 additions and 3 deletions

View File

@ -141,6 +141,7 @@ Nazara Development Kit:
- ⚠️ TextAreaWidget now support text selection (WIP) - ⚠️ TextAreaWidget now support text selection (WIP)
- ⚠️ TextAreaWidget::GetHoveredGlyph now returns a two-dimensional position instead of a single glyph position - ⚠️ TextAreaWidget::GetHoveredGlyph now returns a two-dimensional position instead of a single glyph position
- Fixed Entity::OnEntityDestruction signal not being properly moved and thus not being called. - Fixed Entity::OnEntityDestruction signal not being properly moved and thus not being called.
- Fixed EntityOwner move assignment which was losing entity ownership
# 0.4: # 0.4:

View File

@ -25,7 +25,7 @@ namespace Ndk
EntityOwner& operator=(Entity* entity); EntityOwner& operator=(Entity* entity);
EntityOwner& operator=(const EntityOwner& handle) = delete; EntityOwner& operator=(const EntityOwner& handle) = delete;
EntityOwner& operator=(EntityOwner&& handle) noexcept = default; EntityOwner& operator=(EntityOwner&& handle) noexcept;
}; };
} }

View File

@ -31,7 +31,6 @@ namespace Ndk
* *
* \see Reset * \see Reset
*/ */
inline EntityOwner::~EntityOwner() inline EntityOwner::~EntityOwner()
{ {
Reset(nullptr); Reset(nullptr);
@ -68,13 +67,26 @@ namespace Ndk
* *
* \param entity Entity to own * \param entity Entity to own
*/ */
inline EntityOwner& EntityOwner::operator=(Entity* entity) inline EntityOwner& EntityOwner::operator=(Entity* entity)
{ {
Reset(entity); Reset(entity);
return *this; return *this;
} }
/*!
* \brief Steals ownership of a EntityOwner
*
* \param handle Handle to the new entity to own, or an invalid handle
*/
inline EntityOwner& EntityOwner::operator=(EntityOwner&& handle) noexcept
{
Reset(); //< Kill previously owned entity, if any
EntityHandle::operator=(std::move(handle));
return *this;
}
} }
namespace std namespace std