-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
base: master
Are you sure you want to change the base?
Add clips to tracks and tracks to track containers only after the constructor completes #7594
Conversation
There was a problem hiding this 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?
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 |
Wait, nevermind, whatever |
64b8f86
to
3c0c167
Compare
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. |
f8d545b
to
f20d308
Compare
…pe of track where it should not be possible)
Already called when constructing clips
… pattern tracks with observer function
If you simply erase the unique_ptr from the vector on removal, then when we reach the destructor of the derived track, the unique_ptr will be empty, and any attempt to read the array of tracks in the parent track container will result in a track being read that is nullptr. The same can be said for clips. To fix this, we need to first make the unique_ptr release ownership of the object, remove the empty unique_ptr from the array, and then delete the object.
Removed m_tracksMutex as it was far too error prone, and we already have requestChangeInModel/doneChangeInModel (which should be the only lock used IMO, that way we only have to worry about removing one lock for real-time safety).
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.