mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 19:03:23 +00:00
Empty image hashes are not valid
I don't know how those arose in the first place, but an empty QByteArray is never a valid hash value for an image. So we should not store those in our translation tables and also get rid of them when loading the tables from disk. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
cac40bd659
commit
1ab5db3726
1 changed files with 16 additions and 0 deletions
|
@ -1026,6 +1026,20 @@ void read_hashes()
|
|||
stream >> thumbnailCache;
|
||||
hashfile.close();
|
||||
}
|
||||
localFilenameOf.remove("");
|
||||
QMutableHashIterator<QString, QByteArray> iter(hashOf);
|
||||
while (iter.hasNext()) {
|
||||
iter.next();
|
||||
if (iter.value().isEmpty())
|
||||
iter.remove();
|
||||
}
|
||||
qDebug() << "localFilenameOf empty" << localFilenameOf[""];
|
||||
|
||||
QHash<QString, QImage>::const_iterator i = thumbnailCache.constBegin();
|
||||
while (i != thumbnailCache.constEnd()) {
|
||||
qDebug() << i.key() << *i;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
void write_hashes()
|
||||
|
@ -1046,6 +1060,8 @@ void write_hashes()
|
|||
|
||||
void add_hash(const QString filename, QByteArray hash)
|
||||
{
|
||||
if (hash.isEmpty())
|
||||
return;
|
||||
QMutexLocker locker(&hashOfMutex);
|
||||
hashOf[filename] = hash;
|
||||
localFilenameOf[hash] = filename;
|
||||
|
|
Loading…
Add table
Reference in a new issue