Merge branch 'VitaminCpp-missing_move_semantics_fix'

This commit is contained in:
Wojtek Figat
2025-12-09 10:00:55 +01:00

View File

@@ -33,6 +33,13 @@ public:
{ {
} }
ScriptingObjectReferenceBase(ScriptingObjectReferenceBase&& other) noexcept
: _object(nullptr)
{
OnSet(other._object);
other.OnSet(nullptr);
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ScriptingObjectReferenceBase"/> class. /// Initializes a new instance of the <see cref="ScriptingObjectReferenceBase"/> class.
/// </summary> /// </summary>
@@ -96,6 +103,16 @@ protected:
void OnSet(ScriptingObject* object); void OnSet(ScriptingObject* object);
void OnDeleted(ScriptingObject* obj); void OnDeleted(ScriptingObject* obj);
ScriptingObjectReferenceBase& operator=(ScriptingObjectReferenceBase&& other) noexcept
{
if (this != &other)
{
OnSet(other._object);
other.OnSet(nullptr);
}
return *this;
}
}; };
/// <summary> /// <summary>
@@ -133,6 +150,11 @@ public:
{ {
} }
ScriptingObjectReference(ScriptingObjectReference&& other) noexcept
: ScriptingObjectReferenceBase(MoveTemp(other))
{
}
/// <summary> /// <summary>
/// Finalizes an instance of the <see cref="ScriptingObjectReference"/> class. /// Finalizes an instance of the <see cref="ScriptingObjectReference"/> class.
/// </summary> /// </summary>
@@ -173,6 +195,12 @@ public:
return *this; return *this;
} }
ScriptingObjectReference& operator=(ScriptingObjectReference&& other) noexcept
{
ScriptingObjectReferenceBase::operator=(MoveTemp(other));
return *this;
}
FORCE_INLINE ScriptingObjectReference& operator=(const Guid& id) FORCE_INLINE ScriptingObjectReference& operator=(const Guid& id)
{ {
OnSet(static_cast<ScriptingObject*>(FindObject(id, T::GetStaticClass()))); OnSet(static_cast<ScriptingObject*>(FindObject(id, T::GetStaticClass())));