aboutsummaryrefslogtreecommitdiff
path: root/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp
diff options
context:
space:
mode:
authorflow <flowlnlnln@gmail.com>2022-09-16 19:25:53 -0300
committerflow <flowlnlnln@gmail.com>2022-09-16 20:12:30 -0300
commit10493bd44ab59171ac4f2e3ab7b600bcff8e4af6 (patch)
treeccce878c5564c02c8b20020cdefbc9e1aa169b85 /launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp
parent9e35230467267691ce745429de8d7e0b18095084 (diff)
downloadPrismLauncher-10493bd44ab59171ac4f2e3ab7b600bcff8e4af6.tar.gz
PrismLauncher-10493bd44ab59171ac4f2e3ab7b600bcff8e4af6.tar.bz2
PrismLauncher-10493bd44ab59171ac4f2e3ab7b600bcff8e4af6.zip
fix: move newly allocated resources to the main thread
This avoids them getting deleted when the worker thread exits, due to thread affinity on the created thread. Signed-off-by: flow <flowlnlnln@gmail.com>
Diffstat (limited to 'launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp')
-rw-r--r--launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp b/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp
index afe892f4..40a6ba18 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();
@@ -98,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