Skip to content

Commit

Permalink
Do not crash on shutdown (#355)
Browse files Browse the repository at this point in the history
- ogreRoot may be nullptr
- Do not destroy textures already scheduled for destruction

Signed-off-by: Matias N. Goldberg <[email protected]>
  • Loading branch information
darksylinc authored Jun 28, 2021
1 parent fb0fb6e commit 7816937
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions ogre2/src/Ogre2RenderEngine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,19 @@ void Ogre2RenderEngine::Destroy()
delete this->ogreOverlaySystem;
this->ogreOverlaySystem = nullptr;

// Clean up any textures that may still be in flight.
Ogre::TextureGpuManager *mgr =
if (this->ogreRoot)
{
// Clean up any textures that may still be in flight.
Ogre::TextureGpuManager *mgr =
this->ogreRoot->getRenderSystem()->getTextureGpuManager();

auto entries = mgr->getEntries();
for (auto& [name, entry] : entries)
{
if (entry.resourceGroup == "General")
mgr->destroyTexture(entry.texture);
}
auto entries = mgr->getEntries();
for (auto& [name, entry] : entries)
{
if (entry.resourceGroup == "General" && !entry.destroyRequested)
mgr->destroyTexture(entry.texture);
}

if (this->ogreRoot)
{
try
{
// TODO(anyone): do we need to catch segfault on delete?
Expand Down

0 comments on commit 7816937

Please sign in to comment.