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

Slightly cleaner handling of composition load failure

parent 88c0e8b9
......@@ -844,7 +844,10 @@ void ProjectManager::updateTimeline(int pos, int scrollPos)
Mlt::Tractor tractor(s);
m_mainTimelineModel = TimelineItemModel::construct(&pCore->getCurrentProfile()->profile(), m_project->getGuideModel(), m_project->commandStack());
pCore->window()->getMainTimeline()->setModel(m_mainTimelineModel);
constructTimelineFromMelt(m_mainTimelineModel, tractor);
if (!constructTimelineFromMelt(m_mainTimelineModel, tractor)) {
//TODO: act on project load failure
qDebug()<<"// Project failed to load!!";
}
const QString groupsData = m_project->getDocumentProperty(QStringLiteral("groups"));
if (!groupsData.isEmpty()) {
m_mainTimelineModel->loadGroups(groupsData);
......
......@@ -112,7 +112,6 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin
qDebug() << "ERROR: Unexpected item in the timeline";
}
}
ok = true;
// Loading compositions
QScopedPointer<Mlt::Service> service(tractor.producer());
......@@ -133,6 +132,7 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin
service.reset(service->producer());
}
// 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()) {
......@@ -147,9 +147,9 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin
continue;
}
ok = 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 (!ok) {
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);
......@@ -164,12 +164,12 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin
timeline->buildTrackCompositing();
timeline->updateDuration();
/*if (!ok) {
if (!ok) {
// TODO log error
// Don't abort loading because of failed composition
undo();
return false;
}*/
}
if (!m_errorMessage.isEmpty()) {
KMessageBox::sorry(qApp->activeWindow(), m_errorMessage.join("\n"), i18n("Problems found in your project file"));
}
......
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