mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-27 13:44:15 +01:00
-fixed the memory leaks of the source menu images
This commit is contained in:
parent
098b5c342b
commit
c06ff6877f
@ -526,15 +526,26 @@ void CButtonsMgr::setText(s16 id, const wstringEx &text, u32 startline,bool unwr
|
||||
void CButtonsMgr::setBtnTexture(s16 id, STexture &texNormal, STexture &texSelected)
|
||||
{
|
||||
if (id == -1) return;
|
||||
SButtonTextureSet texSet;
|
||||
|
||||
texSet.center = texNormal;
|
||||
texSet.centerSel = texSelected;
|
||||
|
||||
if (id < (s32)m_elts.size())
|
||||
{
|
||||
SButton *b = (SButton*)m_elts[id];
|
||||
b->tex = texSet;//change texture
|
||||
/* free old textures */
|
||||
b->tex.center.Cleanup();
|
||||
b->tex.centerSel.Cleanup();
|
||||
/*change textures */
|
||||
b->tex.center = texNormal;
|
||||
b->tex.centerSel = texSelected;
|
||||
}
|
||||
}
|
||||
|
||||
void CButtonsMgr::freeBtnTexture(s16 id)
|
||||
{
|
||||
if(id == -1) return;
|
||||
if(id < (s32)m_elts.size())
|
||||
{
|
||||
SButton *b = (SButton*)m_elts[id];
|
||||
b->tex.center.Cleanup();
|
||||
b->tex.centerSel.Cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,7 @@ public:
|
||||
void setText(s16 id, const wstringEx &text, bool unwrap = false);
|
||||
void setText(s16 id, const wstringEx &text, u32 startline, bool unwrap = false);
|
||||
void setBtnTexture(s16 id, STexture &texNormal, STexture &texSelected);
|
||||
void freeBtnTexture(s16 id);
|
||||
void setTexture(s16 id ,STexture &bg);
|
||||
void setTexture(s16 id, STexture &bg, int width, int height);
|
||||
void setProgress(s16 id, float f, bool instant = false);
|
||||
|
@ -60,7 +60,10 @@ void CMenu::_hideSource(bool instant)
|
||||
}
|
||||
|
||||
for(i = 0; i < 12; ++i)
|
||||
{
|
||||
m_btnMgr.hide(m_sourceBtnSource[i], instant);
|
||||
m_btnMgr.freeBtnTexture(m_sourceBtnSource[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void CMenu::_showSource(void)
|
||||
@ -100,7 +103,7 @@ void CMenu::_updateSourceBtns(void)
|
||||
for (u8 i = 0; i < 12; ++i)
|
||||
m_btnMgr.hide(m_sourceBtnSource[i], true);
|
||||
|
||||
string ImgName;
|
||||
const char *ImgName = NULL;
|
||||
u8 j = (Source_curPage - 1) * 12;
|
||||
|
||||
for(u8 i = 0; i < 12; ++i)
|
||||
@ -108,22 +111,22 @@ void CMenu::_updateSourceBtns(void)
|
||||
STexture texConsoleImg;
|
||||
STexture texConsoleImgs;
|
||||
|
||||
ImgName = m_source.getString(fmt("BUTTON_%i", i + j),"image", "");
|
||||
if(texConsoleImg.fromImageFile(fmt("%s/%s", m_themeDataDir.c_str(), ImgName.c_str())) != TE_OK)
|
||||
ImgName = m_source.getString(fmt("BUTTON_%i", i + j),"image", "").c_str();
|
||||
if(texConsoleImg.fromImageFile(fmt("%s/%s", m_themeDataDir.c_str(), ImgName)) != TE_OK)
|
||||
{
|
||||
if(texConsoleImg.fromImageFile(fmt("%s/%s", m_sourceDir.c_str(), ImgName.c_str())) != TE_OK)
|
||||
if(texConsoleImg.fromImageFile(fmt("%s/%s", m_sourceDir.c_str(), ImgName)) != TE_OK)
|
||||
texConsoleImg.fromPNG(favoriteson_png);
|
||||
}
|
||||
ImgName = m_source.getString(fmt("BUTTON_%i", i + j),"image_s", "");
|
||||
if(texConsoleImgs.fromImageFile(fmt("%s/%s", m_themeDataDir.c_str(), ImgName.c_str())) != TE_OK)
|
||||
ImgName = m_source.getString(fmt("BUTTON_%i", i + j),"image_s", "").c_str();
|
||||
if(texConsoleImgs.fromImageFile(fmt("%s/%s", m_themeDataDir.c_str(), ImgName)) != TE_OK)
|
||||
{
|
||||
if(texConsoleImgs.fromImageFile(fmt("%s/%s", m_sourceDir.c_str(), ImgName.c_str())) != TE_OK)
|
||||
if(texConsoleImgs.fromImageFile(fmt("%s/%s", m_sourceDir.c_str(), ImgName)) != TE_OK)
|
||||
texConsoleImgs.fromPNG(favoritesons_png);
|
||||
}
|
||||
m_btnMgr.setBtnTexture(m_sourceBtnSource[i], texConsoleImg, texConsoleImgs);
|
||||
|
||||
string source = m_source.getString(fmt("BUTTON_%i", i + j), "source", "");
|
||||
if (!source.empty())
|
||||
const char *source = m_source.getString(fmt("BUTTON_%i", i + j), "source", "").c_str();
|
||||
if(source != NULL && source[0] != '\0')
|
||||
m_btnMgr.show(m_sourceBtnSource[i]);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user