Commit 9a06f627 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle

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

Fixes #711
parent 141c8848
...@@ -1274,6 +1274,14 @@ QMap<QString, QString> KdenliveDoc::documentProperties() ...@@ -1274,6 +1274,14 @@ QMap<QString, QString> KdenliveDoc::documentProperties()
return m_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() void KdenliveDoc::loadDocumentProperties()
{ {
QDomNodeList list = m_document.elementsByTagName(QStringLiteral("playlist")); QDomNodeList list = m_document.elementsByTagName(QStringLiteral("playlist"));
...@@ -1302,12 +1310,6 @@ void KdenliveDoc::loadDocumentProperties() ...@@ -1302,12 +1310,6 @@ void KdenliveDoc::loadDocumentProperties()
value.prepend(m_documentRoot); value.prepend(m_documentRoot);
} }
m_documentProperties.insert(name, value); 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 { } else {
m_documentProperties.insert(name, e.firstChild().nodeValue()); m_documentProperties.insert(name, e.firstChild().nodeValue());
} }
......
...@@ -100,6 +100,8 @@ public: ...@@ -100,6 +100,8 @@ public:
QPoint zone() const; QPoint zone() const;
/** @brief Returns target tracks (video, audio). */ /** @brief Returns target tracks (video, audio). */
QPair<int, int> targetTracks() const; QPair<int, int> targetTracks() const;
/** @brief Load document guides from properties. */
void loadDocumentGuides();
void setDocumentProperty(const QString &name, const QString &value); void setDocumentProperty(const QString &name, const QString &value);
virtual const QString getDocumentProperty(const QString &name, const QString &defaultValue = QString()) const; virtual const QString getDocumentProperty(const QString &name, const QString &defaultValue = QString()) const;
......
...@@ -552,6 +552,7 @@ void ProjectManager::doOpenFile(const QUrl &url, KAutoSaveFile *stale) ...@@ -552,6 +552,7 @@ void ProjectManager::doOpenFile(const QUrl &url, KAutoSaveFile *stale)
// Set default target tracks to upper audio / lower video tracks // Set default target tracks to upper audio / lower video tracks
m_project = doc; m_project = doc;
doc->loadDocumentGuides();
if (!updateTimeline(m_project->getDocumentProperty(QStringLiteral("position")).toInt())) { if (!updateTimeline(m_project->getDocumentProperty(QStringLiteral("position")).toInt())) {
delete m_progressDialog; delete m_progressDialog;
......
...@@ -3157,8 +3157,8 @@ bool TimelineModel::replantCompositions(int currentCompo, bool updateView) ...@@ -3157,8 +3157,8 @@ bool TimelineModel::replantCompositions(int currentCompo, bool updateView)
Mlt::Transition &transition = *m_allCompositions[compo.second].get(); Mlt::Transition &transition = *m_allCompositions[compo.second].get();
transition.set_tracks(aTrack, compo.first); transition.set_tracks(aTrack, compo.first);
int ret = field->plant_transition(transition, 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() /*qDebug() << "Planting composition " << compo.second << "in " << aTrack << "/" << compo.first << "IN = " << m_allCompositions[compo.second]->getIn()
<< "OUT = " << m_allCompositions[compo.second]->getOut() << "ret=" << ret; << "OUT = " << m_allCompositions[compo.second]->getOut() << "ret=" << ret;*/
mlt_service consumer = mlt_service_consumer(transition.get_service()); mlt_service consumer = mlt_service_consumer(transition.get_service());
Q_ASSERT(consumer != nullptr); Q_ASSERT(consumer != nullptr);
...@@ -3182,7 +3182,7 @@ bool TimelineModel::replantCompositions(int currentCompo, bool updateView) ...@@ -3182,7 +3182,7 @@ bool TimelineModel::replantCompositions(int currentCompo, bool updateView)
bool TimelineModel::unplantComposition(int compoId) bool TimelineModel::unplantComposition(int compoId)
{ {
qDebug() << "Unplanting" << compoId; //qDebug() << "Unplanting" << compoId;
Mlt::Transition &transition = *m_allCompositions[compoId].get(); Mlt::Transition &transition = *m_allCompositions[compoId].get();
mlt_service consumer = mlt_service_consumer(transition.get_service()); mlt_service consumer = mlt_service_consumer(transition.get_service());
Q_ASSERT(consumer != nullptr); 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