Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Swap to a safer pattern for Node ownership, where the Layout will act as the sole factory and owner of Nodes/Contexts and clean them up for you.
Note about design choices regarding lifetimes: The Layout must outlive Nodes unless
destroyNodehas been called, in which case all instances of Node with the same internal reference become invalid, and using them becomes undefined behavior. You can still easily use invalid references without care if your UI changes the tree structure at runtime! For example, ChildRanges are intended to be ephemeral, and you should not add or remove children while iterating. Hanging on to references to nodes you may delete later is a bad idea and an easy way to encounter an assertion, or worse, a crash. Have a plan to clean them up if you remove them - Yoga is intended to be used as a C-like API, so some diligence is still required (but not as much). View "Node" instances as dumb pointers that act like references and "Layout" as the source of truth for node and context lifetimes that will clean up created nodes and their contexts for you.This PR also adds a GTest suite, which consist mostly of sanity checks, since this library doesn't add much besides safer context access and more convenient cleanup.
Update docs to reflect API changes