mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
fix(ResourceFolderModel): don't read state from off-thread task
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
1cd78bf94a
commit
6cb07e203b
2 changed files with 13 additions and 6 deletions
|
|
@ -38,9 +38,12 @@ ResourceFolderModel::ResourceFolderModel(const QDir& dir, BaseInstance* instance
|
||||||
m_dir.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware);
|
m_dir.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware);
|
||||||
|
|
||||||
connect(&m_watcher, &QFileSystemWatcher::directoryChanged, this, &ResourceFolderModel::directoryChanged);
|
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
|
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);
|
Qt::ConnectionType::QueuedConnection);
|
||||||
|
|
||||||
m_helper_thread_task.addTask(task);
|
m_resourceResolver.addTask(task);
|
||||||
|
|
||||||
if (!m_helper_thread_task.isRunning()) {
|
if (!m_resourceResolverRunning) {
|
||||||
QThreadPool::globalInstance()->start(&m_helper_thread_task);
|
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.
|
// Represents the relationship between a resource's internal ID and it's row position on the model.
|
||||||
QMap<QString, int> m_resources_index;
|
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;
|
QMap<int, Task::Ptr> m_active_parse_tasks;
|
||||||
std::atomic<int> m_next_resolution_ticket = 0;
|
std::atomic<int> m_next_resolution_ticket = 0;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue