fix: memory leak with NetJob and responce not getting cleaned up

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
Rachel Powers
2023-05-21 01:46:28 -07:00
parent d5c6a1b4d1
commit 1b3ff96ffd
8 changed files with 140 additions and 79 deletions

View File

@ -138,7 +138,7 @@ void ConcurrentTask::startNext()
connect(next.get(), &Task::progress, this, [this, next](qint64 current, qint64 total) { subTaskProgress(next, current, total); });
m_doing.insert(next.get(), next);
auto task_progress = std::make_shared<TaskStepProgress>(TaskStepProgress({ next->getUid() }));
auto task_progress = std::make_shared<TaskStepProgress>(next->getUid());
m_task_progress.insert(next->getUid(), task_progress);
updateState();
@ -166,9 +166,9 @@ void ConcurrentTask::subTaskSucceeded(Task::Ptr task)
disconnect(task.get(), 0, this, 0);
emit stepProgress(*task_progress.get());
emit stepProgress(*task_progress);
updateState();
updateStepProgress(*task_progress.get(), Operation::REMOVED);
updateStepProgress(*task_progress, Operation::REMOVED);
startNext();
}
@ -184,9 +184,9 @@ void ConcurrentTask::subTaskFailed(Task::Ptr task, const QString& msg)
disconnect(task.get(), 0, this, 0);
emit stepProgress(*task_progress.get());
emit stepProgress(*task_progress);
updateState();
updateStepProgress(*task_progress.get(), Operation::REMOVED);
updateStepProgress(*task_progress, Operation::REMOVED);
startNext();
}
@ -196,7 +196,7 @@ void ConcurrentTask::subTaskStatus(Task::Ptr task, const QString& msg)
task_progress->status = msg;
task_progress->state = TaskStepState::Running;
emit stepProgress(*task_progress.get());
emit stepProgress(*task_progress);
if (totalSize() == 1) {
setStatus(msg);
@ -209,7 +209,7 @@ void ConcurrentTask::subTaskDetails(Task::Ptr task, const QString& msg)
task_progress->details = msg;
task_progress->state = TaskStepState::Running;
emit stepProgress(*task_progress.get());
emit stepProgress(*task_progress);
if (totalSize() == 1) {
setDetails(msg);
@ -220,15 +220,10 @@ void ConcurrentTask::subTaskProgress(Task::Ptr task, qint64 current, qint64 tota
{
auto task_progress = m_task_progress.value(task->getUid());
task_progress->old_current = task_progress->current;
task_progress->old_total = task_progress->old_total;
task_progress->current = current;
task_progress->total = total;
task_progress->state = TaskStepState::Running;
emit stepProgress(*task_progress.get());
updateStepProgress(*task_progress.get(), Operation::CHANGED);
task_progress->update(current, total);
emit stepProgress(*task_progress);
updateStepProgress(*task_progress, Operation::CHANGED);
updateState();
if (totalSize() == 1) {

View File

@ -109,7 +109,7 @@ void Task::start()
return;
}
}
// NOTE: only fall thorugh to here in end states
// NOTE: only fall through to here in end states
m_state = State::Running;
emit started();
executeTask();

View File

@ -64,7 +64,21 @@ struct TaskStepProgress {
QString status = "";
QString details = "";
TaskStepState state = TaskStepState::Waiting;
TaskStepProgress() {
this->uid = QUuid::createUuid();
}
TaskStepProgress(QUuid uid) {
this->uid = uid;
}
bool isDone() const { return (state == TaskStepState::Failed) || (state == TaskStepState::Succeeded); }
void update(qint64 current, qint64 total) {
this->old_current = this->current;
this->old_total = this->total;
this->current = current;
this->total = total;
this->state = TaskStepState::Running;
}
};
Q_DECLARE_METATYPE(TaskStepProgress)