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

Add clips to tracks and tracks to track containers only after the constructor completes #7594

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

sakertooth
Copy link
Contributor

@sakertooth sakertooth commented Nov 23, 2024

Currently, we add tracks and clips prematurely to there respective containers, i.e., they are added within the base class. This has seemed to have caused a number of problems involving calls to pure virtual functions (because the object wasn't fully created yet), to dynamic_cast failures and ultimately crashes. This PR fixes this by only adding a track or clip to their respective containers after the object has been fully constructed.

include/AutomationTrack.h Outdated Show resolved Hide resolved
Copy link
Contributor

@Rossmaxx Rossmaxx left a comment

Choose a reason for hiding this comment

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

A few thoughts. Another doubt I have is that, does this fix that crash with deleting a track while playing?

src/core/Track.cpp Outdated Show resolved Hide resolved
src/core/Track.cpp Outdated Show resolved Hide resolved
@sakertooth
Copy link
Contributor Author

A few thoughts. Another doubt I have is that, does this fix that crash with deleting a track while playing?

I believe crashes like those happen because of synchronization issues involving mutexes (which I believe should be fixed, albeit not ideally). What I am addressing here with this PR is the problem where we are adding clips to tracks and tracks to track containers (like the song editor) way too early. If I created a SampleTrack object for example, it would add itself to the song editor when its constructor hasn't completed yet. This has caused a number of bugs when processing the Song.

@sakertooth
Copy link
Contributor Author

sakertooth commented Nov 23, 2024

A few thoughts. Another doubt I have is that, does this fix that crash with deleting a track while playing?

Wow, I discovered something. When tracks are deleted, only the base destructor is called (Track::~Track) and not the derived one (maybe something like SampleTrack::~SampleTrack for example) because the destructor isn't virtual. Destructors like SampleTrack::~SampleTrack remove all play handles associated with that track, but it may not be ran when deleting it at all. I'm just realizing how many issues need to be fixed here.

Wait, nevermind, whatever Track inherits have virtual destructors already. I do remember that we covered these cases with a clang-tidy PR awhile back actually.

@sakertooth sakertooth changed the title Improve the creational correctness of tracks and clips Improve ownership semantics involving tracks and clips Nov 23, 2024
@sakertooth sakertooth changed the title Improve ownership semantics involving tracks and clips Improve creational correctness involving tracks and clips Nov 23, 2024
@sakertooth sakertooth added needs code review A functional code review is currently required for this PR needs testing This pull request needs more testing and removed needs code review A functional code review is currently required for this PR labels Nov 23, 2024
src/core/Track.cpp Outdated Show resolved Hide resolved
@sakertooth sakertooth marked this pull request as draft November 25, 2024 02:48
@sakertooth sakertooth force-pushed the creational-correctness-tracks-clips branch from 64b8f86 to 3c0c167 Compare November 25, 2024 04:40
@sakertooth
Copy link
Contributor Author

PR too big. Started over. This PR is only concerned with delaying the addition of clips to tracks and tracks to track containers after the constructor is complete.

@sakertooth sakertooth changed the title Improve creational correctness involving tracks and clips Add clips to tracks and tracks to track containers only after the constructor completes Nov 25, 2024
@sakertooth sakertooth marked this pull request as ready for review November 25, 2024 04:45
@sakertooth sakertooth marked this pull request as draft November 29, 2024 23:57
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