summaryrefslogtreecommitdiffstats
path: root/core/qthelper.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-03-07 16:37:31 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-05-13 13:52:35 -0700
commitf60343eebbf6a31a4643dde9f4454f6ce84f61d3 (patch)
tree160871fa52c6973c1d9e1459df6c98d6b5db19a4 /core/qthelper.cpp
parent5d372cfda3770207ce95e6d64ac2ee141681421b (diff)
downloadsubsurface-f60343eebbf6a31a4643dde9f4454f6ce84f61d3.tar.gz
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>
Diffstat (limited to 'core/qthelper.cpp')
-rw-r--r--core/qthelper.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/core/qthelper.cpp b/core/qthelper.cpp
index 93c4c20f5..797dbf932 100644
--- a/core/qthelper.cpp
+++ b/core/qthelper.cpp
@@ -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() {