Android: Fix memory leak when displaying images in the mainmenu (#8011)

This commit is contained in:
rubenwardy 2018-12-22 07:46:41 +00:00 committed by Loïc Blot
parent a318bceb63
commit 0990ddb3bb

@ -72,20 +72,28 @@ video::ITexture *MenuTextureSource::getTexture(const std::string &name, u32 *id)
{ {
if (id) if (id)
*id = 0; *id = 0;
if (name.empty()) if (name.empty())
return NULL; return NULL;
m_to_delete.insert(name); m_to_delete.insert(name);
#ifdef __ANDROID__ #ifdef __ANDROID__
video::ITexture *retval = m_driver->findTexture(name.c_str());
if (retval)
return retval;
video::IImage *image = m_driver->createImageFromFile(name.c_str()); video::IImage *image = m_driver->createImageFromFile(name.c_str());
if (image) { if (!image)
return NULL;
image = Align2Npot2(image, m_driver); image = Align2Npot2(image, m_driver);
video::ITexture* retval = m_driver->addTexture(name.c_str(), image); retval = m_driver->addTexture(name.c_str(), image);
image->drop(); image->drop();
return retval; return retval;
} #else
#endif
return m_driver->getTexture(name.c_str()); return m_driver->getTexture(name.c_str());
#endif
} }
/******************************************************************************/ /******************************************************************************/