Skip to content

Commit 0990ddb

Browse files
rubenwardynerzhul
authored andcommittedDec 22, 2018
Android: Fix memory leak when displaying images in the mainmenu (#8011)
1 parent a318bce commit 0990ddb

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed
 

‎src/gui/guiEngine.cpp

+17-9
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,30 @@ MenuTextureSource::~MenuTextureSource()
7070
/******************************************************************************/
7171
video::ITexture *MenuTextureSource::getTexture(const std::string &name, u32 *id)
7272
{
73-
if(id)
73+
if (id)
7474
*id = 0;
75-
if(name.empty())
75+
76+
if (name.empty())
7677
return NULL;
78+
7779
m_to_delete.insert(name);
7880

7981
#ifdef __ANDROID__
80-
video::IImage *image = m_driver->createImageFromFile(name.c_str());
81-
if (image) {
82-
image = Align2Npot2(image, m_driver);
83-
video::ITexture* retval = m_driver->addTexture(name.c_str(), image);
84-
image->drop();
82+
video::ITexture *retval = m_driver->findTexture(name.c_str());
83+
if (retval)
8584
return retval;
86-
}
87-
#endif
85+
86+
video::IImage *image = m_driver->createImageFromFile(name.c_str());
87+
if (!image)
88+
return NULL;
89+
90+
image = Align2Npot2(image, m_driver);
91+
retval = m_driver->addTexture(name.c_str(), image);
92+
image->drop();
93+
return retval;
94+
#else
8895
return m_driver->getTexture(name.c_str());
96+
#endif
8997
}
9098

9199
/******************************************************************************/

0 commit comments

Comments
 (0)
Please sign in to comment.