summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-models/divepicturemodel.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/qt-models/divepicturemodel.cpp b/qt-models/divepicturemodel.cpp
index d135e0faa..41035aba2 100644
--- a/qt-models/divepicturemodel.cpp
+++ b/qt-models/divepicturemodel.cpp
@@ -8,20 +8,26 @@
#include <QtConcurrent>
extern QHash <QString, QImage> thumbnailCache;
+static QMutex thumbnailMutex;
void scaleImages(PictureEntry &entry)
{
+ QMutexLocker l(&thumbnailMutex);
if (thumbnailCache.contains(entry.filename) && !thumbnailCache.value(entry.filename).isNull()) {
entry.image = thumbnailCache.value(entry.filename);
- } else {
- int dim = defaultIconMetrics().sz_pic;
- QImage p = SHashedImage(entry.picture);
- if(!p.isNull()) {
- p = p.scaled(dim, dim, Qt::KeepAspectRatio);
+ return;
+ }
+ l.unlock();
+
+ int dim = defaultIconMetrics().sz_pic;
+ QImage p = SHashedImage(entry.picture);
+ if(!p.isNull()) {
+ p = p.scaled(dim, dim, Qt::KeepAspectRatio);
+ QMutexLocker l(&thumbnailMutex);
+ if (!thumbnailCache.contains(entry.filename))
thumbnailCache.insert(entry.filename, p);
- }
- entry.image = p;
}
+ entry.image = p;
}
DivePictureModel *DivePictureModel::instance()