Erasing the element invalidates the iterator so this is not possible in a simple range-based for loop causing a crash.
I encountered this when configuring a setup with multiple renderWindows, the program crashed during shutdown of the ogre root. We used renderWindow->destroy() to clean up the window, now we use Ogre::Root::getSingleton().destroyRenderTarget(renderWindow) instead because this circumvents the erase call in the loop. But I figured I would submit a pull request to fix the for loop anyway.
Erasing the element invalidates the iterator so this is not possible in a simple range-based for loop causing a crash.
I encountered this when configuring a setup with multiple renderWindows, the program crashed during shutdown of the ogre root. We used
renderWindow->destroy()
to clean up the window, now we useOgre::Root::getSingleton().destroyRenderTarget(renderWindow)
instead because this circumvents theerase
call in the loop. But I figured I would submit a pull request to fix the for loop anyway.