So I was having segfault in the ControllerManager::updateAllControllers because nullptr object was used.
Debugging showed me that mControllers vector was modified inside range based loop and then ci
object was 0. I tested and found that ControllerManager::createController
was called within loop.
Modifying container we are iterating over must cause problems, but what I'm not sure if such modification is expected.
Changes below fixes the issue, but I want to double check that calling ControllerManager::createController
from update() is possible. And I'm totally unfamiliar with all this controllers and what they can do.
Code: Select all
void ControllerManager::updateAllControllers(void)
{
// Only update once per frame
unsigned long thisFrameNumber = Root::getSingleton().getNextFrameNumber();
if (thisFrameNumber != mLastFrameNumber)
{
// master version
//for (auto *ci : mControllers)
//{
// ci->update();
//}
for (size_t i = 0; i < mControllers.size(); ++i)
{
mControllers[i]->update();
}
mLastFrameNumber = thisFrameNumber;
}
}