mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-18 14:40:56 +00:00
Limit box art fetching to a single thread to improve UI responsiveness
This commit is contained in:
@@ -6,8 +6,10 @@
|
|||||||
|
|
||||||
BoxArtManager::BoxArtManager(QObject *parent) :
|
BoxArtManager::BoxArtManager(QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_BoxArtDir(Path::getBoxArtCacheDir())
|
m_BoxArtDir(Path::getBoxArtCacheDir()),
|
||||||
|
m_ThreadPool(this)
|
||||||
{
|
{
|
||||||
|
m_ThreadPool.setMaxThreadCount(1);
|
||||||
if (!m_BoxArtDir.exists()) {
|
if (!m_BoxArtDir.exists()) {
|
||||||
m_BoxArtDir.mkpath(".");
|
m_BoxArtDir.mkpath(".");
|
||||||
}
|
}
|
||||||
@@ -41,7 +43,7 @@ QUrl BoxArtManager::loadBoxArt(NvComputer* computer, NvApp& app)
|
|||||||
// If we get here, we need to fetch asynchronously.
|
// If we get here, we need to fetch asynchronously.
|
||||||
// Kick off a worker on our thread pool to do just that.
|
// Kick off a worker on our thread pool to do just that.
|
||||||
NetworkBoxArtLoadTask* netLoadTask = new NetworkBoxArtLoadTask(this, computer, app);
|
NetworkBoxArtLoadTask* netLoadTask = new NetworkBoxArtLoadTask(this, computer, app);
|
||||||
QThreadPool::globalInstance()->start(netLoadTask);
|
m_ThreadPool.start(netLoadTask);
|
||||||
|
|
||||||
// Return the placeholder then we can notify the caller
|
// Return the placeholder then we can notify the caller
|
||||||
// later when the real image is ready.
|
// later when the real image is ready.
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ private:
|
|||||||
getFilePathForBoxArt(NvComputer* computer, int appId);
|
getFilePathForBoxArt(NvComputer* computer, int appId);
|
||||||
|
|
||||||
QDir m_BoxArtDir;
|
QDir m_BoxArtDir;
|
||||||
|
QThreadPool m_ThreadPool;
|
||||||
};
|
};
|
||||||
|
|
||||||
class NetworkBoxArtLoadTask : public QObject, public QRunnable
|
class NetworkBoxArtLoadTask : public QObject, public QRunnable
|
||||||
|
|||||||
Reference in New Issue
Block a user