Skip to content

Commit

Permalink
call destructor in ComponentArray::erase()
Browse files Browse the repository at this point in the history
  • Loading branch information
Bashar-Ahmed authored and r41k0u committed Aug 24, 2023
1 parent e46a5ab commit 2aac4d7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rootex/framework/component.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class Component
/// Perform setting up operations which are possible only after all entities have been set up.
virtual bool setupEntities() { return true; }
/// Perform operations prior to detachment from owning entity and destruction.
virtual void onRemove() { this->~Component(); }
virtual void onRemove() { }

Entity& getOwner() { return *m_Owner; }
virtual ComponentID getComponentID() const = 0;
Expand Down
2 changes: 2 additions & 0 deletions rootex/utility/component_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class ComponentArray
{
m_IsValid[i] = false;
m_Data[i].onRemove();
m_Data[i].~Component();
memset(&m_Data[i], 0, sizeof(m_Data[i]));
m_ArraySize--;
return true;
}
Expand Down

0 comments on commit 2aac4d7

Please sign in to comment.