Commit 01f6e42d authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle

Fix several slideshows incorrectly share same thumbnail if in same folder

parent bfff60a1
......@@ -986,9 +986,10 @@ const QString ProjectClip::hash()
return getFileHash();
}
const QByteArray ProjectClip::getFolderHash(QDir dir)
const QByteArray ProjectClip::getFolderHash(QDir dir, QString fileName)
{
QByteArray fileData = dir.entryList(QDir::Files).join(QLatin1Char(',')).toUtf8();
fileName.append(dir.entryList(QDir::Files).join(QLatin1Char(',')));
QByteArray fileData = fileName.toUtf8();
return QCryptographicHash::hash(fileData, QCryptographicHash::Md5);
}
......@@ -998,7 +999,7 @@ const QString ProjectClip::getFileHash()
QByteArray fileHash;
switch (m_clipType) {
case ClipType::SlideShow:
fileHash = getFolderHash(QFileInfo(clipUrl()).absoluteDir());
fileHash = getFolderHash(QFileInfo(clipUrl()).absoluteDir(), QFileInfo(clipUrl()).fileName());
break;
case ClipType::Text:
fileData = getProducerProperty(QStringLiteral("xmldata")).toUtf8();
......
......@@ -244,7 +244,7 @@ public:
/** @brief Get the list of audio stream effects for a defined stream. */
QStringList getAudioStreamEffect(int streamIndex) const override;
/** @brief Calculate the folder's hash (based on the files it contains). */
static const QByteArray getFolderHash(QDir dir);
static const QByteArray getFolderHash(QDir dir, QString fileName);
/** @brief Check if the clip is included in timeline and reset its occurences on producer reload. */
void updateTimelineOnReload();
......
......@@ -294,9 +294,11 @@ bool DocumentChecker::hasErrorInClips()
continue;
}
// Check for slideshows
QString slidePattern;
bool slideshow = resource.contains(QStringLiteral("/.all.")) || resource.contains(QLatin1Char('?')) || resource.contains(QLatin1Char('%'));
if (slideshow) {
if (service == QLatin1String("qimage") || service == QLatin1String("pixbuf")) {
slidePattern = QFileInfo(resource).fileName();
resource = QFileInfo(resource).absolutePath();
} else if (service.startsWith(QLatin1String("avformat")) && Xml::hasXmlProperty(e, QStringLiteral("ttl"))) {
// Fix MLT 6.20 avformat slideshows
......@@ -332,7 +334,7 @@ bool DocumentChecker::hasErrorInClips()
// Check if file changed
const QByteArray hash = Xml::getXmlProperty(e, "kdenlive:file_hash").toLatin1();
if (!hash.isEmpty()) {
const QByteArray fileData = slideshow ? ProjectClip::getFolderHash(QDir(resource)).toHex() : ProjectClip::calculateHash(resource).first.toHex();
const QByteArray fileData = slideshow ? ProjectClip::getFolderHash(QDir(resource), slidePattern).toHex() : ProjectClip::calculateHash(resource).first.toHex();
if (hash != fileData) {
// For slideshow clips, silently upgrade hash
if (slideshow) {
......@@ -1019,7 +1021,7 @@ QString DocumentChecker::searchDirRecursively(const QDir &dir, const QString &ma
QStringList filesAndDirs;
QString fileName = QFileInfo(fullName).fileName();
// Check main dir
QString fileHash = ProjectClip::getFolderHash(dir).toHex();
QString fileHash = ProjectClip::getFolderHash(dir, fileName).toHex();
if (fileHash == matchHash) {
return dir.absoluteFilePath(fileName);
}
......@@ -1027,7 +1029,7 @@ QString DocumentChecker::searchDirRecursively(const QDir &dir, const QString &ma
const QStringList subDirs = dir.entryList(QDir::AllDirs | QDir::NoDot | QDir::NoDotDot);
for (const QString &sub : subDirs) {
QDir subFolder(dir.absoluteFilePath(sub));
fileHash = ProjectClip::getFolderHash(subFolder).toHex();
fileHash = ProjectClip::getFolderHash(subFolder, fileName).toHex();
if (fileHash == matchHash) {
return subFolder.absoluteFilePath(fileName);
}
......
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