Commit f6048bd1 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix crash on mix group move, fix mix sometimes refusing to be created

parent 1bb25c61
......@@ -703,12 +703,13 @@ bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool
// Insert mix on new track
bool result = getTrackById_const(trackId)->createMix(mixData.first, mixParams, finalMove);
// Remove mix on old track
getTrackById_const(previous_track)->syncronizeMixes(finalMove);
getTrackById_const(previous_track)->removeMix(mixData.first);
return result;
};
simple_restore_mix = [this, previous_track, trackId, finalMove, mixData, mixParams]() {
bool result = getTrackById_const(previous_track)->createMix(mixData.first, mixParams, finalMove);
getTrackById_const(trackId)->syncronizeMixes(finalMove);
// Remove mix on old track
getTrackById_const(trackId)->removeMix(mixData.first);
return result;
};
}
......
......@@ -719,6 +719,7 @@ Fun TrackModel::requestClipResize_lambda(int clipId, int in, int out, bool right
}
return err == 0;
};
} else {
}
blank = target_clip + 1;
} else {
......@@ -730,7 +731,7 @@ Fun TrackModel::requestClipResize_lambda(int clipId, int in, int out, bool right
}
if (m_playlists[target_track].is_blank(blank)) {
int blank_length = m_playlists[target_track].clip_length(blank);
if (blank_length + delta >= 0 && (hasMix || other_blank_end >= out)) {
if (blank_length + delta >= 0 && (hasMix || other_blank_end >= out - in)) {
return [blank_length, blank, right, clipId, delta, update_snaps, this, in, out, target_clip, target_track]() {
if (isLocked()) return false;
int target_clip_mutable = target_clip;
......@@ -2198,6 +2199,18 @@ void TrackModel::setMixDuration(int cid, int mixDuration, int mixCut)
m_sameCompositions[cid]->dataChanged(QModelIndex(), QModelIndex(), {AssetParameterModel::ParentDurationRole});
}
void TrackModel::removeMix(MixInfo info)
{
Q_ASSERT(m_sameCompositions.count(info.secondClipId) > 0);
Mlt::Transition &transition = *static_cast<Mlt::Transition*>(m_sameCompositions[info.secondClipId]->getAsset());
QScopedPointer<Mlt::Field> field(m_track->field());
field->lock();
field->disconnect_service(transition);
field->unlock();
m_sameCompositions.erase(info.secondClipId);
m_mixList.remove(info.firstClipId);
}
void TrackModel::syncronizeMixes(bool finalMove)
{
QList<int>toDelete;
......
......@@ -140,6 +140,8 @@ public:
void switchMix(int cid, const QString composition, Fun &undo, Fun &redo);
/** @brief Ensure we don't have unsynced mixes in the playlist (mixes without owner clip) */
void syncronizeMixes(bool finalMove);
/** @brief Remove a mix in the track (if its clip was removed) */
void removeMix(MixInfo info);
/** @brief Switch a clip from one playlist to the other */
bool switchPlaylist(int clipId, int position, int sourcePlaylist, int destPlaylist);
/** @brief Load a same track transition from project */
......
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