Improve missing luma detection (region transition) - fixes project crash

parent 9f3fcc96
...@@ -65,6 +65,16 @@ DocumentChecker::DocumentChecker(const QUrl &url, const QDomDocument &doc) ...@@ -65,6 +65,16 @@ DocumentChecker::DocumentChecker(const QUrl &url, const QDomDocument &doc)
{ {
} }
QMap <QString, QString> DocumentChecker::getLumaPairs() const
{
QMap <QString, QString> lumaSearchPairs;
lumaSearchPairs.insert(QStringLiteral("luma"), QStringLiteral("resource"));
lumaSearchPairs.insert(QStringLiteral("movit.luma_mix"), QStringLiteral("resource"));
lumaSearchPairs.insert(QStringLiteral("composite"), QStringLiteral("luma"));
lumaSearchPairs.insert(QStringLiteral("region"), QStringLiteral("composite.luma"));
return lumaSearchPairs;
}
bool DocumentChecker::hasErrorInClips() bool DocumentChecker::hasErrorInClips()
{ {
int max; int max;
...@@ -225,16 +235,16 @@ bool DocumentChecker::hasErrorInClips() ...@@ -225,16 +235,16 @@ bool DocumentChecker::hasErrorInClips()
QStringList missingLumas; QStringList missingLumas;
QStringList filesToCheck; QStringList filesToCheck;
QString filePath; QString filePath;
QMap <QString, QString>lumaSearchPairs = getLumaPairs();
QDomNodeList trans = m_doc.elementsByTagName(QStringLiteral("transition")); QDomNodeList trans = m_doc.elementsByTagName(QStringLiteral("transition"));
max = trans.count(); max = trans.count();
for (int i = 0; i < max; ++i) { for (int i = 0; i < max; ++i) {
QDomElement transition = trans.at(i).toElement(); QDomElement transition = trans.at(i).toElement();
QString service = getProperty(transition, QStringLiteral("mlt_service")); QString service = getProperty(transition, QStringLiteral("mlt_service"));
QString luma; QString luma;
if (service == QLatin1String("luma")) { if (lumaSearchPairs.contains(service)) {
luma = getProperty(transition, QStringLiteral("resource")); luma = getProperty(transition, lumaSearchPairs.value(service));
} else if (service == QLatin1String("composite")) {
luma = getProperty(transition, QStringLiteral("luma"));
} }
if (!luma.isEmpty() && !filesToCheck.contains(luma)) { if (!luma.isEmpty() && !filesToCheck.contains(luma)) {
filesToCheck.append(luma); filesToCheck.append(luma);
...@@ -291,13 +301,11 @@ bool DocumentChecker::hasErrorInClips() ...@@ -291,13 +301,11 @@ bool DocumentChecker::hasErrorInClips()
QDomElement transition = trans.at(i).toElement(); QDomElement transition = trans.at(i).toElement();
QString service = getProperty(transition, QStringLiteral("mlt_service")); QString service = getProperty(transition, QStringLiteral("mlt_service"));
QString luma; QString luma;
if (service == QLatin1String("luma")) { if (lumaSearchPairs.contains(service)) {
luma = getProperty(transition, QStringLiteral("resource")); luma = getProperty(transition, lumaSearchPairs.value(service));
} else if (service == QLatin1String("composite")) {
luma = getProperty(transition, QStringLiteral("luma"));
} }
if (!luma.isEmpty() && autoFixLuma.contains(luma)) { if (!luma.isEmpty() && autoFixLuma.contains(luma)) {
updateProperty(transition, service == QLatin1String("luma") ? QStringLiteral("resource") : QStringLiteral("luma"), autoFixLuma.value(luma)); updateProperty(transition, lumaSearchPairs.value(service), autoFixLuma.value(luma));
} }
} }
} }
...@@ -1011,30 +1019,28 @@ void DocumentChecker::fixClipItem(QTreeWidgetItem *child, const QDomNodeList &pr ...@@ -1011,30 +1019,28 @@ void DocumentChecker::fixClipItem(QTreeWidgetItem *child, const QDomNodeList &pr
} }
} }
} else if (child->data(0, statusRole).toInt() == LUMAOK) { } else if (child->data(0, statusRole).toInt() == LUMAOK) {
QMap <QString, QString>lumaSearchPairs = getLumaPairs();
for (int i = 0; i < trans.count(); ++i) { for (int i = 0; i < trans.count(); ++i) {
QString service = getProperty(trans.at(i).toElement(), QStringLiteral("mlt_service")); QString service = getProperty(trans.at(i).toElement(), QStringLiteral("mlt_service"));
QString luma; QString luma;
if (service == QLatin1String("luma")) { if (lumaSearchPairs.contains(service)) {
luma = getProperty(trans.at(i).toElement(), QStringLiteral("resource")); luma = getProperty(trans.at(i).toElement(), lumaSearchPairs.value(service));
} else if (service == QLatin1String("composite")) {
luma = getProperty(trans.at(i).toElement(), QStringLiteral("luma"));
} }
if (!luma.isEmpty() && luma == child->data(0, idRole).toString()) { if (!luma.isEmpty() && luma == child->data(0, idRole).toString()) {
updateProperty(trans.at(i).toElement(), service == QLatin1String("luma") ? QStringLiteral("resource") : QStringLiteral("luma"), child->text(1)); updateProperty(trans.at(i).toElement(), lumaSearchPairs.value(service), child->text(1));
// qCDebug(KDENLIVE_LOG) << "replace with; " << child->text(1); // qCDebug(KDENLIVE_LOG) << "replace with; " << child->text(1);
} }
} }
} else if (child->data(0, statusRole).toInt() == LUMAMISSING) { } else if (child->data(0, statusRole).toInt() == LUMAMISSING) {
QMap <QString, QString>lumaSearchPairs = getLumaPairs();
for (int i = 0; i < trans.count(); ++i) { for (int i = 0; i < trans.count(); ++i) {
QString service = getProperty(trans.at(i).toElement(), QStringLiteral("mlt_service")); QString service = getProperty(trans.at(i).toElement(), QStringLiteral("mlt_service"));
QString luma; QString luma;
if (service == QLatin1String("luma")) { if (lumaSearchPairs.contains(service)) {
luma = getProperty(trans.at(i).toElement(), QStringLiteral("resource")); luma = getProperty(trans.at(i).toElement(), lumaSearchPairs.value(service));
} else if (service == QLatin1String("composite")) {
luma = getProperty(trans.at(i).toElement(), QStringLiteral("luma"));
} }
if (!luma.isEmpty() && luma == child->data(0, idRole).toString()) { if (!luma.isEmpty() && luma == child->data(0, idRole).toString()) {
updateProperty(trans.at(i).toElement(), service == QLatin1String("luma") ? QStringLiteral("resource") : QStringLiteral("luma"), QString()); updateProperty(trans.at(i).toElement(), lumaSearchPairs.value(service), QString());
} }
} }
} }
...@@ -1101,18 +1107,17 @@ void DocumentChecker::slotDeleteSelected() ...@@ -1101,18 +1107,17 @@ void DocumentChecker::slotDeleteSelected()
if (!deletedLumas.isEmpty()) { if (!deletedLumas.isEmpty()) {
QDomElement e; QDomElement e;
QDomNodeList transitions = m_doc.elementsByTagName(QStringLiteral("transition")); QDomNodeList transitions = m_doc.elementsByTagName(QStringLiteral("transition"));
QMap <QString, QString>lumaSearchPairs = getLumaPairs();
for (const QString &lumaPath : deletedLumas) { for (const QString &lumaPath : deletedLumas) {
for (int i = 0; i < transitions.count(); ++i) { for (int i = 0; i < transitions.count(); ++i) {
e = transitions.item(i).toElement(); e = transitions.item(i).toElement();
QString service = EffectsList::property(e, QStringLiteral("mlt_service")); QString service = EffectsList::property(e, QStringLiteral("mlt_service"));
QString resource; QString resource;
if (service == QLatin1String("luma")) { if (lumaSearchPairs.contains(service)) {
resource = EffectsList::property(e, QStringLiteral("resource")); resource = getProperty(e, lumaSearchPairs.value(service));
} else if (service == QLatin1String("composite")) {
resource = EffectsList::property(e, QStringLiteral("luma"));
} }
if (resource == lumaPath) { if (!resource.isEmpty() && resource == lumaPath) {
EffectsList::removeProperty(e, service == QLatin1String("luma") ? QStringLiteral("resource") : QStringLiteral("luma")); EffectsList::removeProperty(e, lumaSearchPairs.value(service));
} }
} }
} }
......
...@@ -78,6 +78,8 @@ private: ...@@ -78,6 +78,8 @@ private:
void fixClipItem(QTreeWidgetItem *child, const QDomNodeList &producers, const QDomNodeList &trans); void fixClipItem(QTreeWidgetItem *child, const QDomNodeList &producers, const QDomNodeList &trans);
void fixSourceClipItem(QTreeWidgetItem *child, const QDomNodeList &producers); void fixSourceClipItem(QTreeWidgetItem *child, const QDomNodeList &producers);
void fixProxyClip(const QString &id, const QString &oldUrl, const QString &newUrl, const QDomNodeList &producers); void fixProxyClip(const QString &id, const QString &oldUrl, const QString &newUrl, const QDomNodeList &producers);
/** @brief Returns list of transitions containg luma files */
QMap <QString, QString> getLumaPairs() const;
}; };
#endif #endif
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