From 1ea9dc469b3052abcb4af02017f1d09e74940426 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Tue, 21 Dec 2021 15:57:46 +0100 Subject: [PATCH] Use global threadpool --- src/BlurhashProvider.h | 9 +++------ src/JdenticonProvider.cpp | 5 ++--- src/JdenticonProvider.h | 11 ++--------- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/BlurhashProvider.h b/src/BlurhashProvider.h index 73b95eee..7f6f31c9 100644 --- a/src/BlurhashProvider.h +++ b/src/BlurhashProvider.h @@ -34,12 +34,12 @@ private: class BlurhashResponse : public QQuickImageResponse { public: - BlurhashResponse(const QString &id, const QSize &requestedSize, QThreadPool *pool) + BlurhashResponse(const QString &id, const QSize &requestedSize) { auto runnable = new BlurhashRunnable(id, requestedSize); connect(runnable, &BlurhashRunnable::done, this, &BlurhashResponse::handleDone); connect(runnable, &BlurhashRunnable::error, this, &BlurhashResponse::handleError); - pool->start(runnable); + QThreadPool::globalInstance()->start(runnable); } QQuickTextureFactory *textureFactory() const override @@ -72,9 +72,6 @@ public slots: QQuickImageResponse * requestImageResponse(const QString &id, const QSize &requestedSize) override { - return new BlurhashResponse(id, requestedSize, &pool); + return new BlurhashResponse(id, requestedSize); } - -private: - QThreadPool pool; }; diff --git a/src/JdenticonProvider.cpp b/src/JdenticonProvider.cpp index f0360ad6..e69e42e0 100644 --- a/src/JdenticonProvider.cpp +++ b/src/JdenticonProvider.cpp @@ -70,12 +70,11 @@ clipRadius(QPixmap img, double radius) JdenticonResponse::JdenticonResponse(const QString &key, bool crop, double radius, - const QSize &requestedSize, - QThreadPool *pool) + const QSize &requestedSize) { auto runnable = new JdenticonRunnable(key, crop, radius, requestedSize); connect(runnable, &JdenticonRunnable::done, this, &JdenticonResponse::handleDone); - pool->start(runnable); + QThreadPool::globalInstance()->start(runnable); } JdenticonRunnable::JdenticonRunnable(const QString &key, diff --git a/src/JdenticonProvider.h b/src/JdenticonProvider.h index b387b3c1..c355eae7 100644 --- a/src/JdenticonProvider.h +++ b/src/JdenticonProvider.h @@ -36,11 +36,7 @@ private: class JdenticonResponse : public QQuickImageResponse { public: - JdenticonResponse(const QString &key, - bool crop, - double radius, - const QSize &requestedSize, - QThreadPool *pool); + JdenticonResponse(const QString &key, bool crop, double radius, const QSize &requestedSize); QQuickTextureFactory *textureFactory() const override { @@ -86,9 +82,6 @@ public slots: } } - return new JdenticonResponse(id_, crop, radius, requestedSize, &pool); + return new JdenticonResponse(id_, crop, radius, requestedSize); } - -private: - QThreadPool pool; };