Use global threadpool

This commit is contained in:
Nicolas Werner 2021-12-21 15:57:46 +01:00
parent 8edc46dc16
commit 1ea9dc469b
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
3 changed files with 7 additions and 18 deletions

View file

@ -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;
};

View file

@ -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,

View file

@ -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;
};