-
Notifications
You must be signed in to change notification settings - Fork 168
Closed
Milestone
Description
For very historical reasons, our handling of referring to member objects of games (via the GameObject and GameObjectPtr system) conflates two logically distinct considerations:
- The validity of an object (that is, whether it continues to refer to a legitimate part of the game, or has been deleted at some point by some operation);
- The reference counting of pointers to an object (to ensure memory gets deallocated correctly).
This leads to object deletion at potentially surprising times, because in GameObject there is a place where delete this is called - which is not ideal, even if it is technically legal. Without being exceptionally careful one can easily enough create a situation where an operation is attempted on an object that was deleted as part of the Invalidate() call on it.
- Use
std::shared_ptrandstd::weak_ptras appropriate to handle memory management of game component objects - Create a new variation on
GameObjectPtrwhich stores astd::shared_ptrto the object, and checks for validity, but which does not have any responsibility for reference counting.
Metadata
Metadata
Assignees
Labels
No labels