fix(TaskManager): memory leak #4949 (#4950)

This commit is contained in:
Aleksandar Fabijanic
2025-05-19 11:44:28 +02:00
committed by GitHub
parent a9bc5e148f
commit 5e5e1a60f9

View File

@@ -67,14 +67,20 @@ bool TaskManager::start(Task* pTask)
pTask->setState(Task::TASK_STARTING);
try
{
{
ScopedLockT lock(_mutex);
_taskList.push_back(pAutoTask);
}
_threadPool.start(*pTask, pTask->name());
ScopedLockT lock(_mutex);
_taskList.push_back(pAutoTask);
return true;
}
catch (...)
{
pTask->setOwner(nullptr);
ScopedLockT lock(_mutex);
auto it = std::find(_taskList.begin(), _taskList.end(), pTask);
if (it != _taskList.end()) _taskList.erase(it);
throw;
}
}