Skip to content
Permalink
Browse files

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

  • Loading branch information...
rubenwardy authored and nerzhul committed Dec 22, 2018
1 parent a318bce commit 0990ddb3bb96ab2e4c7a1ee44ed79c4218477949
Showing with 17 additions and 9 deletions.
  1. +17 −9 src/gui/guiEngine.cpp
@@ -70,22 +70,30 @@ MenuTextureSource::~MenuTextureSource()
/******************************************************************************/
video::ITexture *MenuTextureSource::getTexture(const std::string &name, u32 *id)
{
if(id)
if (id)
*id = 0;
if(name.empty())

if (name.empty())
return NULL;

m_to_delete.insert(name);

#ifdef __ANDROID__
video::IImage *image = m_driver->createImageFromFile(name.c_str());
if (image) {
image = Align2Npot2(image, m_driver);
video::ITexture* retval = m_driver->addTexture(name.c_str(), image);
image->drop();
video::ITexture *retval = m_driver->findTexture(name.c_str());
if (retval)
return retval;
}
#endif

video::IImage *image = m_driver->createImageFromFile(name.c_str());
if (!image)
return NULL;

image = Align2Npot2(image, m_driver);
retval = m_driver->addTexture(name.c_str(), image);
image->drop();
return retval;
#else
return m_driver->getTexture(name.c_str());
#endif
}

/******************************************************************************/

0 comments on commit 0990ddb

Please sign in to comment.
You can’t perform that action at this time.