mirror of
https://github.com/PrismLauncher/PrismLauncher
synced 2026-04-23 09:05:03 +00:00
fix(ResourceFolderModel): don't read state from off-thread task
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
(cherry picked from commit 6cb07e203b)
This commit is contained in:
parent
d531abb684
commit
03de3bbe91
|
|
@ -38,9 +38,12 @@ ResourceFolderModel::ResourceFolderModel(const QDir& dir, BaseInstance* instance
|
|||
m_dir.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware);
|
||||
|
||||
connect(&m_watcher, &QFileSystemWatcher::directoryChanged, this, &ResourceFolderModel::directoryChanged);
|
||||
connect(&m_helper_thread_task, &ConcurrentTask::finished, this, [this] { m_helper_thread_task.clear(); });
|
||||
connect(&m_resourceResolver, &ConcurrentTask::finished, this, [this] {
|
||||
m_resourceResolver.clear();
|
||||
m_resourceResolverRunning = false;
|
||||
});
|
||||
if (APPLICATION_DYN) { // in tests the application macro doesn't work
|
||||
m_helper_thread_task.setMaxConcurrent(APPLICATION->settings()->get("NumberOfConcurrentTasks").toInt());
|
||||
m_resourceResolver.setMaxConcurrent(APPLICATION->settings()->get("NumberOfConcurrentTasks").toInt());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -382,10 +385,11 @@ void ResourceFolderModel::resolveResource(Resource::Ptr res)
|
|||
},
|
||||
Qt::ConnectionType::QueuedConnection);
|
||||
|
||||
m_helper_thread_task.addTask(task);
|
||||
m_resourceResolver.addTask(task);
|
||||
|
||||
if (!m_helper_thread_task.isRunning()) {
|
||||
QThreadPool::globalInstance()->start(&m_helper_thread_task);
|
||||
if (!m_resourceResolverRunning) {
|
||||
QThreadPool::globalInstance()->start(&m_resourceResolver);
|
||||
m_resourceResolverRunning = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -261,7 +261,10 @@ class ResourceFolderModel : public QAbstractListModel {
|
|||
// Represents the relationship between a resource's internal ID and it's row position on the model.
|
||||
QMap<QString, int> m_resources_index;
|
||||
|
||||
ConcurrentTask m_helper_thread_task;
|
||||
// Runs off-thread
|
||||
ConcurrentTask m_resourceResolver;
|
||||
bool m_resourceResolverRunning = false;
|
||||
|
||||
QMap<int, Task::Ptr> m_active_parse_tasks;
|
||||
std::atomic<int> m_next_resolution_ticket = 0;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue