mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Dive pictures: replace picture struct by QString
In imagedownloader.cpp the only thing we need from the picture struct is the filename. Therefore, use QStrings instead of the picture struct. This simplifies memory management. Remove the clone_picture() function, which is not needed anymore. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
5d372cfda3
commit
f60343eebb
7 changed files with 29 additions and 58 deletions
|
|
@ -1240,23 +1240,20 @@ QString localFilePath(const QString &originalFilename)
|
|||
return originalFilename;
|
||||
}
|
||||
|
||||
// This needs to operate on a copy of picture as it frees it after finishing!
|
||||
void hashPicture(struct picture *picture)
|
||||
// This works on a copy of the string, because it runs in asynchronous context
|
||||
void hashPicture(QString filename)
|
||||
{
|
||||
if (!picture)
|
||||
return;
|
||||
QByteArray oldHash = getHash(QString(picture->filename));
|
||||
QByteArray hash = hashFile(localFilePath(picture->filename));
|
||||
QByteArray oldHash = getHash(filename);
|
||||
QByteArray hash = hashFile(localFilePath(filename));
|
||||
if (!hash.isNull() && hash != oldHash)
|
||||
mark_divelist_changed(true);
|
||||
picture_free(picture);
|
||||
}
|
||||
|
||||
extern "C" void cache_picture(struct picture *picture)
|
||||
{
|
||||
QString filename = picture->filename;
|
||||
if (!haveHash(filename))
|
||||
QtConcurrent::run(hashPicture, clone_picture(picture));
|
||||
QtConcurrent::run(hashPicture, filename);
|
||||
}
|
||||
|
||||
QStringList imageExtensionFilters() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue