OGRECave / ogre

scene-oriented, flexible 3D engine (C++, Python, C#, Java)
https://ogrecave.github.io/ogre/
MIT License
3.91k stars 963 forks source link

Either increment the iterator or assign when erasing #3160

Closed FrankGoyens closed 1 month ago

FrankGoyens commented 1 month ago

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.

paroj commented 1 month ago

rather reverting the commit that introduced the issue #3161