Optimize document check on opening

svn path=/trunk/kdenlive/; revision=5985
parent a54db1d1
......@@ -78,6 +78,8 @@ bool DocumentChecker::hasErrorInClips()
QDomNodeList documentProducers = m_doc.elementsByTagName("producer");
QList <QDomElement> wrongDurationClips;
QList <QDomElement> missingProxies;
m_safeImages.clear();
m_safeFonts.clear();
max = m_info.count();
for (int i = 0; i < max; i++) {
e = m_info.item(i).toElement();
......@@ -119,16 +121,11 @@ bool DocumentChecker::hasErrorInClips()
}
}
QStringList safeImages;
if (clipType == TEXT) {
//TODO: Check is clip template is missing (xmltemplate) or hash changed
QStringList images = TitleWidget::extractImageList(e.attribute("xmldata"));
QStringList fonts = TitleWidget::extractFontList(e.attribute("xmldata"));
// Make sure we don't check the same images twice
foreach(const QString &existingImage, safeImages) {
images.removeAll(existingImage);
}
safeImages.append(checkMissingImages(images, fonts, e.attribute("id"), e.attribute("name")));
checkMissingImagesAndFonts(images, fonts, e.attribute("id"), e.attribute("name"));
continue;
}
resource = e.attribute("resource");
......@@ -459,7 +456,7 @@ void DocumentChecker::slotSearchClips()
}
QString DocumentChecker::searchLuma(QString file) const
QString DocumentChecker::searchLuma(const QString &file) const
{
KUrl searchPath(KdenliveSettings::mltpath());
if (file.contains("PAL"))
......@@ -835,11 +832,11 @@ void DocumentChecker::slotDeleteSelected()
}
}
QStringList DocumentChecker::checkMissingImages(QStringList images, QStringList fonts, QString id, QString baseClip)
void DocumentChecker::checkMissingImagesAndFonts(QStringList images, QStringList fonts, const QString &id, const QString &baseClip)
{
QDomDocument doc;
QStringList safeImages;
foreach(const QString &img, images) {
if (m_safeImages.contains(img)) continue;
if (!KIO::NetAccess::exists(KUrl(img), KIO::NetAccess::SourceSide, 0)) {
QDomElement e = doc.createElement("missingclip");
e.setAttribute("type", TITLE_IMAGE_ELEMENT);
......@@ -848,12 +845,12 @@ QStringList DocumentChecker::checkMissingImages(QStringList images, QStringList
e.setAttribute("name", baseClip);
m_missingClips.append(e);
}
else safeImages.append(img);
else m_safeImages.append(img);
}
kDebug() << "/ / / CHK FONTS: " << fonts;
foreach(const QString &fontelement, fonts) {
if (m_safeFonts.contains(fontelement)) continue;
QFont f(fontelement);
kDebug() << "/ / / CHK FONTS: " << fontelement << " = " << QFontInfo(f).family();
//kDebug() << "/ / / CHK FONTS: " << fontelement << " = " << QFontInfo(f).family();
if (fontelement != QFontInfo(f).family()) {
QDomElement e = doc.createElement("missingclip");
e.setAttribute("type", TITLE_FONT_ELEMENT);
......@@ -862,8 +859,8 @@ QStringList DocumentChecker::checkMissingImages(QStringList images, QStringList
e.setAttribute("name", baseClip);
m_missingClips.append(e);
}
else m_safeFonts.append(fontelement);
}
return safeImages;
}
......
......@@ -46,9 +46,9 @@ private slots:
void slotDeleteSelected();
QString getProperty(QDomElement effect, const QString &name);
void setProperty(QDomElement effect, const QString &name, const QString value);
QString searchLuma(QString file) const;
QString searchLuma(const QString &file) const;
/** @brief Check if images and fonts in this clip exists, returns a list of images that do exist so we don't check twice. */
QStringList checkMissingImages(QStringList images, QStringList fonts, QString id, QString baseClip);
void checkMissingImagesAndFonts(QStringList images, QStringList fonts, const QString &id, const QString &baseClip);
void slotCheckButtons();
/** @brief Fix duration mismatch issues. */
void slotFixDuration();
......@@ -64,6 +64,8 @@ private:
QMap <QString, QString> m_missingTitleImages;
QMap <QString, QString> m_missingTitleFonts;
QList <QDomElement> m_missingClips;
QStringList m_safeImages;
QStringList m_safeFonts;
};
......
......@@ -1054,10 +1054,16 @@ void DocumentValidator::updateEffects()
}
QDomNodeList effects = m_doc.elementsByTagName("filter");
for(int i = 0; i < effects.count(); ++i) {
int max = effects.count();
QStringList safeEffects;
for(int i = 0; i < max; ++i) {
QDomElement effect = effects.at(i).toElement();
QString effectId = EffectsList::property(effect, "kdenlive_id");
if (safeEffects.contains(effectId)) {
// Do not check the same effect twice if it is at the correct version
// (assume we don't have different versions of the same effect in a project file)
continue;
}
QString effectTag = EffectsList::property(effect, "tag");
QString effectVersionStr = EffectsList::property(effect, "version");
double effectVersion = effectVersionStr.isNull() ? -1 : effectVersionStr.toDouble();
......@@ -1124,6 +1130,7 @@ void DocumentValidator::updateEffects()
EffectsList::setProperty(effect, "version", QLocale().toString(serviceVersion));
}
}
else safeEffects.append(effectId);
}
}
}
......
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