From 02d1878a361ae102f474027a4e9c8b2b540adecc Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Mon, 2 Feb 2026 13:27:36 +0500 Subject: [PATCH] fix: manually copy task info when connecting Signed-off-by: Octol1ttle --- launcher/launch/TaskStepWrapper.cpp | 5 +---- launcher/minecraft/MinecraftLoadAndCheck.cpp | 5 +---- launcher/tasks/Task.cpp | 16 ++++++++++++++++ launcher/tasks/Task.h | 3 +++ 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/launcher/launch/TaskStepWrapper.cpp b/launcher/launch/TaskStepWrapper.cpp index 136057620..acf790a8f 100644 --- a/launcher/launch/TaskStepWrapper.cpp +++ b/launcher/launch/TaskStepWrapper.cpp @@ -23,10 +23,7 @@ void TaskStepWrapper::executeTask() return; } connect(m_task.get(), &Task::finished, this, &TaskStepWrapper::updateFinished); - connect(m_task.get(), &Task::progress, this, &TaskStepWrapper::setProgress); - connect(m_task.get(), &Task::stepProgress, this, &TaskStepWrapper::propagateStepProgress); - connect(m_task.get(), &Task::status, this, &TaskStepWrapper::setStatus); - connect(m_task.get(), &Task::details, this, &TaskStepWrapper::setDetails); + propagateFromOther(m_task.get()); emit progressReportingRequest(); } diff --git a/launcher/minecraft/MinecraftLoadAndCheck.cpp b/launcher/minecraft/MinecraftLoadAndCheck.cpp index d456096d3..198076cc4 100644 --- a/launcher/minecraft/MinecraftLoadAndCheck.cpp +++ b/launcher/minecraft/MinecraftLoadAndCheck.cpp @@ -21,10 +21,7 @@ void MinecraftLoadAndCheck::executeTask() connect(m_task.get(), &Task::succeeded, this, &MinecraftLoadAndCheck::emitSucceeded); connect(m_task.get(), &Task::failed, this, &MinecraftLoadAndCheck::emitFailed); connect(m_task.get(), &Task::aborted, this, [this] { emitFailed(tr("Aborted")); }); - connect(m_task.get(), &Task::progress, this, &MinecraftLoadAndCheck::setProgress); - connect(m_task.get(), &Task::stepProgress, this, &MinecraftLoadAndCheck::propagateStepProgress); - connect(m_task.get(), &Task::status, this, &MinecraftLoadAndCheck::setStatus); - connect(m_task.get(), &Task::details, this, &MinecraftLoadAndCheck::setDetails); + propagateFromOther(m_task.get()); } bool MinecraftLoadAndCheck::canAbort() const diff --git a/launcher/tasks/Task.cpp b/launcher/tasks/Task.cpp index fe5d84bb9..b01b2491c 100644 --- a/launcher/tasks/Task.cpp +++ b/launcher/tasks/Task.cpp @@ -194,6 +194,22 @@ QString Task::failReason() const return m_failReason; } +void Task::propagateFromOther(Task* other) +{ + Q_ASSERT(other); + connect(other, &Task::status, this, &Task::setStatus); + connect(other, &Task::details, this, &Task::setDetails); + connect(other, &Task::progress, this, &Task::setProgress); + connect(other, &Task::stepProgress, this, &Task::propagateStepProgress); + + setStatus(other->getStatus()); + setDetails(other->getDetails()); + setProgress(other->getProgress(), other->getTotalProgress()); + for (const auto& progress : other->getStepProgress()) { + propagateStepProgress(*progress); + } +} + void Task::logWarning(const QString& line) { qWarning() << line; diff --git a/launcher/tasks/Task.h b/launcher/tasks/Task.h index 43e71c8ab..6e7645338 100644 --- a/launcher/tasks/Task.h +++ b/launcher/tasks/Task.h @@ -127,6 +127,9 @@ class Task : public QObject, public QRunnable { QUuid getUid() { return m_uid; } + // Copies the other task's status, details, progress, and step progress to this task; and sets up connections for future propagation + void propagateFromOther(Task* other); + protected: void logWarning(const QString& line);