Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow component tree to be alocated in the heap #1

Merged
merged 1 commit into from
Jul 6, 2024

Conversation

rmed
Copy link
Owner

@rmed rmed commented Jul 6, 2024

Changes

Component objects (and derived) can now be instantiated in the heap (e.g. via new). Parent components will keep track of their children and delete them when being destroyed themselves. When a component is destroyed, it removes itself from its parent.

For components allocated in the stack (e.g. as members of another component) this should have no effect, as they would be deleted automatically in reverse-creation order.

This is inspired by Qt's own tree structure

Extra care must be taken to prevent invalid free() calls when mixing
both heap and stack tree allocations.
@rmed rmed merged commit 5e1633d into main Jul 6, 2024
@rmed rmed deleted the feature/tree-memory-management branch July 6, 2024 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant