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

Explicitly add clips and tracks to their respective containers #7754

Open
wants to merge 25 commits into
base: master
Choose a base branch
from

Conversation

sakertooth
Copy link
Contributor

Currently, we add clips and tracks to tracks and track containers in their base classes. As a consequence for adding it to the container before the object has completely finished constructing, the application can crash at selective moments due to the use of an incomplete object (most commonly by usage from the audio thread).

To fix this, callers must now add clips and tracks to their respective containers explicitly after construction has completed.

This is a continuation of #7594, just without being too ambitious to avoid bugs. There is most likely a lot more refactoring that can be done here to make resource management a bit more safe.

Copy link
Member

@messmerd messmerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested it but it looks good to me

@sakertooth sakertooth added the needs testing This pull request needs more testing label Mar 6, 2025
To allow for extendable behavior and avoid unncecessary coupling (specifically with patterns)
@sakertooth
Copy link
Contributor Author

sakertooth commented Mar 6, 2025

I have made some changes, in particular, making addClip, removeClip, addTrack, and removeTrack all virtual. Now, any behavior that depended on the clip or track being added to the parent in the constructor can happen within these functions as extendable behavior on top of the normal functions.

My next goal, which I might not achieve in this PR, is to remove the Track* and TrackContainer* parameters from the constructors to prevent misuse (e.g. passing in a track to the constructor of a Clip, but then adding it to another track by accident). Edit: Requires sweeping changes, will leave for another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs testing This pull request needs more testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants