Separate thumnail loading to different pool
This commit is contained in:
+8
-4
@@ -30,10 +30,10 @@ void Image::load()
|
||||
emit pixmapLoaded(this);
|
||||
}
|
||||
|
||||
void Image::loadThumbnail()
|
||||
void Image::loadThumbnail(QThreadPool *pool)
|
||||
{
|
||||
if(!m_thumbnail)
|
||||
QThreadPool::globalInstance()->start(new LoadRunable(m_name, this, AnalyzeLevel::None, true));
|
||||
pool->start(new LoadRunable(m_name, this, AnalyzeLevel::None, true));
|
||||
else
|
||||
emit thumbnailLoaded(this);
|
||||
}
|
||||
@@ -102,12 +102,16 @@ ImageRingList::ImageRingList(QObject *parent) : QAbstractItemModel(parent)
|
||||
, m_analyzeLevel(None)
|
||||
{
|
||||
connect(&m_fileSystemWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(dirChanged(QString)));
|
||||
m_thumbPool = new QThreadPool(this);
|
||||
}
|
||||
|
||||
ImageRingList::~ImageRingList()
|
||||
{
|
||||
QThreadPool::globalInstance()->clear();
|
||||
m_thumbPool->clear();
|
||||
|
||||
QThreadPool::globalInstance()->waitForDone();
|
||||
m_thumbPool->waitForDone();
|
||||
}
|
||||
|
||||
bool ImageRingList::setDir(const QString path, const QString ¤tFile)
|
||||
@@ -239,13 +243,13 @@ void ImageRingList::loadThumbnails()
|
||||
{
|
||||
for(auto &img : m_images)
|
||||
{
|
||||
img->loadThumbnail();
|
||||
img->loadThumbnail(m_thumbPool);
|
||||
}
|
||||
}
|
||||
|
||||
void ImageRingList::stopLoading()
|
||||
{
|
||||
QThreadPool::globalInstance()->clear();
|
||||
m_thumbPool->clear();
|
||||
}
|
||||
|
||||
int ImageRingList::imageCount() const
|
||||
|
||||
+3
-1
@@ -10,6 +10,7 @@
|
||||
#include "rawimage.h"
|
||||
|
||||
class ImageRingList;
|
||||
class QThreadPool;
|
||||
|
||||
class Image : public QObject
|
||||
{
|
||||
@@ -26,7 +27,7 @@ class Image : public QObject
|
||||
public:
|
||||
explicit Image(const QString name, int number, ImageRingList *ringList);
|
||||
void load();
|
||||
void loadThumbnail();
|
||||
void loadThumbnail(QThreadPool *pool);
|
||||
void release();
|
||||
QString name() const;
|
||||
RawImage* rawImage();
|
||||
@@ -55,6 +56,7 @@ class ImageRingList : public QAbstractItemModel
|
||||
QFileSystemWatcher m_fileSystemWatcher;
|
||||
bool m_liveMode;
|
||||
AnalyzeLevel m_analyzeLevel;
|
||||
QThreadPool *m_thumbPool;
|
||||
public:
|
||||
explicit ImageRingList(QObject *parent = 0);
|
||||
~ImageRingList();
|
||||
|
||||
Reference in New Issue
Block a user