Don't manually delete Clip if it has a Track

This commit is contained in:
sakertooth
2023-09-26 22:55:16 -04:00
parent 99e628a5ab
commit c5f7ccba49
2 changed files with 13 additions and 4 deletions

View File

@@ -345,6 +345,7 @@ Clip * Track::addClip( Clip * clip )
*/
void Track::removeClip( Clip * clip )
{
auto guard = Engine::audioEngine()->requestChangesGuard();
clipVector::iterator it = std::find( m_clips.begin(), m_clips.end(), clip );
if( it != m_clips.end() )
{
@@ -650,4 +651,4 @@ BoolModel *Track::getMutedModel()
return &m_mutedModel;
}
} // namespace lmms
} // namespace lmms

View File

@@ -284,7 +284,8 @@ bool ClipView::close()
/*! \brief Removes a ClipView from its track view.
*
* Like the close() method, this asks the track view to remove this
* ClipView.
* ClipView. However, the clip is
* scheduled for later deletion rather than closed immediately.
*
*/
void ClipView::remove()
@@ -293,8 +294,15 @@ void ClipView::remove()
// delete ourself
close();
auto guard = Engine::audioEngine()->requestChangesGuard();
delete m_clip;
// Since the Track would own the clip, we don't delete it
if (m_clip->getTrack())
{
m_clip->getTrack()->removeClip(m_clip);
return;
}
m_clip->deleteLater();
}