Ensure mix parenting is updated in case of clip cut

parent 65cba8aa
......@@ -128,6 +128,7 @@ bool TimelineFunctions::processClipCut(const std::shared_ptr<TimelineItemModel>
return false;
}
PlaylistState::ClipState state = timeline->m_allClips[clipId]->clipState();
// Check if clip has an end Mix
bool res = cloneClip(timeline, clipId, newId, state, undo, redo);
timeline->m_blockRefresh = true;
res = res && timeline->requestItemResize(clipId, position - start, true, true, undo, redo);
......@@ -141,6 +142,18 @@ bool TimelineFunctions::processClipCut(const std::shared_ptr<TimelineItemModel>
// The next requestclipmove does not check for duration change since we don't invalidate timeline, so check duration change now
bool durationChanged = trackDuration != timeline->getTrackById_const(trackId)->trackDuration();
res = res && timeline->requestClipMove(newId, trackId, position, true, true, false, true, undo, redo);
if (timeline->getTrackById_const(trackId)->hasEndMix(clipId)) {
Fun local_undo = [timeline, trackId, clipId, newId]() {
timeline->getTrackById_const(trackId)->reAssignEndMix(newId, clipId);
return true; };
Fun local_redo = [timeline, trackId, clipId, newId]() {
timeline->getTrackById_const(trackId)->reAssignEndMix(clipId, newId);
return true; };
local_redo();
UPDATE_UNDO_REDO_NOLOCK(local_redo, local_undo, undo, redo);
}
if (durationChanged) {
// Track length changed, check project duration
Fun updateDuration = [timeline]() {
......
......@@ -2168,3 +2168,12 @@ const std::shared_ptr<AssetParameterModel> TrackModel::mixModel(int cid)
}
return nullptr;
}
bool TrackModel::reAssignEndMix(int currentId, int newId)
{
Q_ASSERT(m_mixList.contains(currentId));
int mixedClip = m_mixList.value(currentId);
m_mixList.remove(currentId);
m_mixList.insert(newId, mixedClip);
return true;
}
......@@ -132,6 +132,9 @@ public:
bool createMix(std::pair<int, int> clipIds, std::pair<int, int> mixData);
/** @brief Create a mix composition using mix info */
bool createMix(MixInfo info, bool isAudio);
/** @brief Change id of first clip in a mix (in case of clip cut) */
bool reAssignEndMix(int currentId, int newId);
/** @brief Ensure we don't have unsynced mixes in the playlist (mixes without owner clip) */
void syncronizeMixes(bool finalMove);
/** @brief Switch a clip from one playlist to the other */
bool switchPlaylist(int clipId, int position, int sourcePlaylist, int destPlaylist);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment