Fix crash on project open and possible guides loss on recovery.

Fixes #711
parent aad2b3d4
Pipeline #22601 passed with stage
in 18 minutes and 47 seconds
......@@ -1275,6 +1275,14 @@ QMap<QString, QString> KdenliveDoc::documentProperties()
return m_documentProperties;
}
void KdenliveDoc::loadDocumentGuides()
{
QString guides = m_documentProperties.value(QStringLiteral("guides"));
if (!guides.isEmpty()) {
m_guideModel->importFromJson(guides, true);
}
}
void KdenliveDoc::loadDocumentProperties()
{
QDomNodeList list = m_document.elementsByTagName(QStringLiteral("playlist"));
......@@ -1303,12 +1311,6 @@ void KdenliveDoc::loadDocumentProperties()
value.prepend(m_documentRoot);
}
m_documentProperties.insert(name, value);
} else if (name == QStringLiteral("guides")) {
QString guides = e.firstChild().nodeValue();
if (!guides.isEmpty()) {
QMetaObject::invokeMethod(m_guideModel.get(), "importFromJson", Qt::QueuedConnection, Q_ARG(const QString &, guides), Q_ARG(bool, true),
Q_ARG(bool, false));
}
} else {
m_documentProperties.insert(name, e.firstChild().nodeValue());
}
......
......@@ -100,6 +100,8 @@ public:
QPoint zone() const;
/** @brief Returns target tracks (video, audio). */
QPair<int, int> targetTracks() const;
/** @brief Load document guides from properties. */
void loadDocumentGuides();
void setDocumentProperty(const QString &name, const QString &value);
virtual const QString getDocumentProperty(const QString &name, const QString &defaultValue = QString()) const;
......
......@@ -586,6 +586,7 @@ void ProjectManager::doOpenFile(const QUrl &url, KAutoSaveFile *stale)
// Set default target tracks to upper audio / lower video tracks
m_project = doc;
doc->loadDocumentGuides();
if (!updateTimeline(m_project->getDocumentProperty(QStringLiteral("position")).toInt())) {
delete m_progressDialog;
......
......@@ -3327,8 +3327,8 @@ bool TimelineModel::replantCompositions(int currentCompo, bool updateView)
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;
/*qDebug() << "Planting composition " << compo.second << "in " << aTrack << "/" << compo.first << "IN = " << m_allCompositions[compo.second]->getIn()
<< "OUT = " << m_allCompositions[compo.second]->getOut() << "ret=" << ret;*/
mlt_service consumer = mlt_service_consumer(transition.get_service());
Q_ASSERT(consumer != nullptr);
......@@ -3352,7 +3352,7 @@ bool TimelineModel::replantCompositions(int currentCompo, bool updateView)
bool TimelineModel::unplantComposition(int compoId)
{
qDebug() << "Unplanting" << compoId;
//qDebug() << "Unplanting" << compoId;
Mlt::Transition &transition = *m_allCompositions[compoId].get();
mlt_service consumer = mlt_service_consumer(transition.get_service());
Q_ASSERT(consumer != nullptr);
......
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