pdf preview generation: Use QtConcurrent::mapped + QFutureWatcher instead of own single-thread solution

This commit is contained in:
2019-04-29 20:50:52 +02:00
bovenliggende 0d3cfefb36
commit 4c8d201f81
6 gewijzigde bestanden met toevoegingen van 77 en 85 verwijderingen

Bestand weergeven

@ -6,29 +6,17 @@
#include <QThread>
#include <QMutex>
#include <QWaitCondition>
#include <QMutex>
#include <QFuture>
#include <poppler-qt5.h>
#include "pdfpreview.h"
#include "searchresult.h"
class PdfWorker : public QObject
{
Q_OBJECT
private:
QHash<QString, Poppler::Document *> documentcache;
Poppler::Document *document(QString path);
std::atomic<bool> cancelCurrent{false};
std::atomic<bool> generating{false};
QMutex isFreeMutex;
QWaitCondition isFree;
public:
PdfWorker();
void cancelAndWait();
public slots:
void generatePreviews(QVector<SearchResult> paths, double scalefactor);
signals:
void previewReady(PdfPreview p);
void previewsFinished();
QFuture<PdfPreview> generatePreviews(QVector<SearchResult> paths, double scalefactor);
};
#endif // PDFWORKER_H