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

Fix crash and corruption on track deletion and group composition move

parent 79e34cd5
......@@ -2373,6 +2373,24 @@ bool TimelineModel::requestTrackDeletion(int trackId, Fun &undo, Fun &redo)
return false;
}
}
std::vector<int> compositions_to_delete;
for (const auto &it : getTrackById(trackId)->m_allCompositions) {
compositions_to_delete.push_back(it.first);
}
for (int compo : compositions_to_delete) {
bool res = true;
while (res && m_groups->isInGroup(compo)) {
res = requestClipUngroup(compo, local_undo, local_redo);
}
if (res) {
res = requestCompositionDeletion(compo, local_undo, local_redo);
}
if (!res) {
bool u = local_undo();
Q_ASSERT(u);
return false;
}
}
int old_position = getTrackPosition(trackId);
int previousTrack = getPreviousVideoTrackPos(trackId);
auto operation = deregisterTrack_lambda(trackId);
......@@ -2941,7 +2959,7 @@ bool TimelineModel::requestCompositionMove(int compoId, int trackId, int positio
int track_pos2 = getTrackPosition(current_trackId);
int delta_track = track_pos1 - track_pos2;
int delta_pos = position - m_allCompositions[compoId]->getPosition();
return requestGroupMove(compoId, groupId, delta_track, delta_pos, updateView, logUndo);
return requestGroupMove(compoId, groupId, delta_track, delta_pos, true, updateView, logUndo);
}
std::function<bool(void)> undo = []() { return true; };
std::function<bool(void)> redo = []() { return true; };
......@@ -3132,12 +3150,11 @@ bool TimelineModel::replantCompositions(int currentCompo, bool updateView)
Q_ASSERT(aTrack != -1 && aTrack < m_tractor->count());
Mlt::Transition &transition = *m_allCompositions[compo.second].get();
transition.set_tracks(aTrack, compo.first);
int ret = field->plant_transition(transition, aTrack, compo.first);
qDebug() << "Planting composition " << compo.second << "in " << aTrack << "/" << compo.first << "IN = " << m_allCompositions[compo.second]->getIn()
<< "OUT = " << m_allCompositions[compo.second]->getOut() << "ret=" << ret;
transition.set_tracks(aTrack, compo.first);
mlt_service consumer = mlt_service_consumer(transition.get_service());
Q_ASSERT(consumer != nullptr);
if (ret != 0) {
......
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