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

Fix the remaining compositing issues reported by Harald (mimick the 18.x behavior)

parent cd371679
Pipeline #4041 passed with stage
in 34 minutes and 57 seconds
......@@ -134,31 +134,28 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin
}
// Sort compositions and insert
bool compositionOk = true;
if (!compositions.isEmpty()) {
std::sort(compositions.begin(), compositions.end(), [](Mlt::Transition *a, Mlt::Transition *b) { return a->get_b_track() > b->get_b_track(); });
while (!compositions.isEmpty()) {
QScopedPointer<Mlt::Transition> t(compositions.takeFirst());
auto transProps = std::make_unique<Mlt::Properties>(t->get_properties());
QString id(t->get("kdenlive_id"));
int compoId;
int aTrack = t->get_a_track();
if (aTrack > tractor.count()) {
m_errorMessage << i18n("Invalid composition %1 found on track %2 at %3, compositing with track %4.", t->get("id"), t->get_b_track(),
while (!compositions.isEmpty()) {
QScopedPointer<Mlt::Transition> t(compositions.takeFirst());
auto transProps = std::make_unique<Mlt::Properties>(t->get_properties());
QString id(t->get("kdenlive_id"));
int compoId;
int aTrack = t->get_a_track();
if (aTrack > tractor.count()) {
m_errorMessage << i18n("Invalid composition %1 found on track %2 at %3, compositing with track %4.", t->get("id"), t->get_b_track(),
t->get_in(), t->get_a_track());
continue;
}
continue;
}
compositionOk = timeline->requestCompositionInsertion(id, timeline->getTrackIndexFromPosition(t->get_b_track() - 1), t->get_a_track(), t->get_in(),
compositionOk = timeline->requestCompositionInsertion(id, timeline->getTrackIndexFromPosition(t->get_b_track() - 1), t->get_a_track(), t->get_in(),
t->get_length(), std::move(transProps), compoId, undo, redo);
if (!compositionOk) {
qDebug() << "ERROR : failed to insert composition in track " << t->get_b_track() << ", position" << t->get_in() << ", ID: " << id
if (!compositionOk) {
qDebug() << "ERROR : failed to insert composition in track " << t->get_b_track() << ", position" << t->get_in() << ", ID: " << id
<< ", MLT ID: " << t->get("id");
// timeline->requestItemDeletion(compoId, false);
m_errorMessage << i18n("Invalid composition %1 found on track %2 at %3.", t->get("id"), t->get_b_track(), t->get_in());
continue;
}
qDebug() << "Inserted composition in track " << t->get_b_track() << ", position" << t->get_in() << "/" << t->get_out();
// timeline->requestItemDeletion(compoId, false);
m_errorMessage << i18n("Invalid composition %1 found on track %2 at %3.", t->get("id"), t->get_b_track(), t->get_in());
continue;
}
qDebug() << "Inserted composition in track " << t->get_b_track() << ", position" << t->get_in() << "/" << t->get_out();
}
// build internal track compositing
......
......@@ -2572,7 +2572,7 @@ bool TimelineModel::requestCompositionMove(int compoId, int trackId, int composi
bool TimelineModel::replantCompositions(int currentCompo, bool updateView)
{
// We ensure that the compositions are planted in a decreasing order of b_track.
// We ensure that the compositions are planted in a decreasing order of a_track, and increasing order of b_track.
// For that, there is no better option than to disconnect every composition and then reinsert everything in the correct order.
std::vector<std::pair<int, int>> compos;
for (const auto &compo : m_allCompositions) {
......@@ -2588,7 +2588,13 @@ bool TimelineModel::replantCompositions(int currentCompo, bool updateView)
}
}
// sort by decreasing b_track
std::sort(compos.begin(), compos.end(), [](const std::pair<int, int> &a, const std::pair<int, int> &b) { return a.first > b.first; });
std::sort(compos.begin(), compos.end(), [&](const std::pair<int, int> &a, const std::pair<int, int> &b) {
if (m_allCompositions[a.second]->getATrack() == m_allCompositions[b.second]->getATrack()) {
return a.first < b.first;
}
return m_allCompositions[a.second]->getATrack() > m_allCompositions[b.second]->getATrack();
});
// replant
QScopedPointer<Mlt::Field> field(m_tractor->field());
field->lock();
......
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