aboutsummaryrefslogtreecommitdiff
path: root/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp')
-rw-r--r--launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp b/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp
index 3a857740..78ef4386 100644
--- a/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp
+++ b/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp
@@ -38,12 +38,23 @@
#include "minecraft/mod/MetadataHandler.h"
+#include <QThread>
+
ModFolderLoadTask::ModFolderLoadTask(QDir mods_dir, QDir index_dir, bool is_indexed, bool clean_orphan)
- : Task(nullptr, false), m_mods_dir(mods_dir), m_index_dir(index_dir), m_is_indexed(is_indexed), m_clean_orphan(clean_orphan), m_result(new Result())
+ : Task(nullptr, false)
+ , m_mods_dir(mods_dir)
+ , m_index_dir(index_dir)
+ , m_is_indexed(is_indexed)
+ , m_clean_orphan(clean_orphan)
+ , m_result(new Result())
+ , m_thread_to_spawn_into(thread())
{}
void ModFolderLoadTask::executeTask()
{
+ if (thread() != m_thread_to_spawn_into)
+ connect(this, &Task::finished, this->thread(), &QThread::quit);
+
if (m_is_indexed) {
// Read metadata first
getFromMetadata();
@@ -57,6 +68,8 @@ void ModFolderLoadTask::executeTask()
if (mod->enabled()) {
if (m_result->mods.contains(mod->internal_id())) {
m_result->mods[mod->internal_id()]->setStatus(ModStatus::Installed);
+ // Delete the object we just created, since a valid one is already in the mods list.
+ delete mod;
}
else {
m_result->mods[mod->internal_id()] = mod;
@@ -86,7 +99,7 @@ void ModFolderLoadTask::executeTask()
// Remove orphan metadata to prevent issues
// See https://github.com/PolyMC/PolyMC/issues/996
if (m_clean_orphan) {
- QMutableMapIterator<QString, Mod::Ptr> iter(m_result->mods);
+ QMutableMapIterator iter(m_result->mods);
while (iter.hasNext()) {
auto mod = iter.next().value();
if (mod->status() == ModStatus::NotInstalled) {
@@ -96,6 +109,9 @@ void ModFolderLoadTask::executeTask()
}
}
+ for (auto mod : m_result->mods)
+ mod->moveToThread(m_thread_to_spawn_into);
+
if (m_aborted)
emit finished();
else