mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-30 01:29:42 -06:00
Fixed some memory leaks. Only one was mine ;P
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7392 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -147,6 +147,12 @@ CGameListCtrl::~CGameListCtrl()
|
||||
{
|
||||
if (m_imageListSmall)
|
||||
delete m_imageListSmall;
|
||||
|
||||
while (!m_ISOFiles.empty()) // so lazy
|
||||
{
|
||||
delete m_ISOFiles.back();
|
||||
m_ISOFiles.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
void CGameListCtrl::InitBitmaps()
|
||||
@ -276,7 +282,7 @@ void CGameListCtrl::Update()
|
||||
for (int i = 0; i < (int)m_ISOFiles.size(); i++)
|
||||
{
|
||||
InsertItemInReportView(i);
|
||||
if (m_ISOFiles[i].IsCompressed())
|
||||
if (m_ISOFiles[i]->IsCompressed())
|
||||
SetItemTextColour(i, wxColour(0xFF0000));
|
||||
}
|
||||
|
||||
@ -375,7 +381,7 @@ void CGameListCtrl::OnPaintDrawImages(wxPaintEvent& event)
|
||||
if (GetItemRect(i, itemRect))
|
||||
{
|
||||
int itemY = itemRect.GetTop();
|
||||
const GameListItem& rISOFile = m_ISOFiles[GetItemData(i)];
|
||||
const GameListItem& rISOFile = *m_ISOFiles[GetItemData(i)];
|
||||
|
||||
m_imageListSmall->Draw(m_PlatformImageIndex[rISOFile.GetPlatform()],
|
||||
dc, itemRect.GetX()+3, itemY);
|
||||
@ -415,7 +421,7 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
|
||||
wxCSConv SJISConv(wxFontMapper::GetEncodingName(wxFONTENCODING_EUC_JP));
|
||||
#endif
|
||||
|
||||
GameListItem& rISOFile = m_ISOFiles[_Index];
|
||||
GameListItem& rISOFile = *m_ISOFiles[_Index];
|
||||
m_gamePath.append(rISOFile.GetFileName() + '\n');
|
||||
|
||||
// Insert a first row with the platform image, that will be used as the Index
|
||||
@ -612,7 +618,9 @@ void CGameListCtrl::ScanForISOs()
|
||||
if (!Cont)
|
||||
break;
|
||||
|
||||
GameListItem ISOFile(rFilenames[i]);
|
||||
GameListItem* const iso_file = new GameListItem(rFilenames[i]);
|
||||
const GameListItem& ISOFile = *iso_file;
|
||||
|
||||
if (ISOFile.IsValid())
|
||||
{
|
||||
bool list = true;
|
||||
@ -665,21 +673,21 @@ void CGameListCtrl::ScanForISOs()
|
||||
}
|
||||
|
||||
if (list)
|
||||
m_ISOFiles.push_back(ISOFile);
|
||||
m_ISOFiles.push_back(iso_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (SConfig::GetInstance().m_ListDrives)
|
||||
{
|
||||
std::vector<std::string> drives = cdio_get_devices();
|
||||
GameListItem * Drive[24];
|
||||
// Another silly Windows limitation of 24 drive letters
|
||||
for (u32 i = 0; i < drives.size() && i < 24; i++)
|
||||
const std::vector<std::string> drives = cdio_get_devices();
|
||||
|
||||
for (std::vector<std::string>::const_iterator iter = drives.begin(); iter != drives.end(); ++iter)
|
||||
{
|
||||
Drive[i] = new GameListItem(drives[i].c_str());
|
||||
if (Drive[i]->IsValid())
|
||||
m_ISOFiles.push_back(*Drive[i]);
|
||||
std::auto_ptr<GameListItem> gli(new GameListItem(*iter));
|
||||
|
||||
if (gli->IsValid())
|
||||
m_ISOFiles.push_back(gli.release());
|
||||
}
|
||||
}
|
||||
|
||||
@ -692,10 +700,12 @@ void CGameListCtrl::OnColBeginDrag(wxListEvent& event)
|
||||
event.Veto();
|
||||
}
|
||||
|
||||
const GameListItem *CGameListCtrl::GetISO(int index) const
|
||||
const GameListItem *CGameListCtrl::GetISO(size_t index) const
|
||||
{
|
||||
if (index >= (int)m_ISOFiles.size()) return NULL;
|
||||
return &m_ISOFiles[index];
|
||||
if (index < m_ISOFiles.size())
|
||||
return m_ISOFiles[index];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CGameListCtrl *caller;
|
||||
@ -906,7 +916,7 @@ void CGameListCtrl::OnMouseMotion(wxMouseEvent& event)
|
||||
return;
|
||||
}
|
||||
|
||||
const GameListItem& rISO = m_ISOFiles[GetItemData(item)];
|
||||
const GameListItem& rISO = *m_ISOFiles[GetItemData(item)];
|
||||
|
||||
IniFile ini;
|
||||
ini.Load(File::GetUserPath(D_GAMECONFIG_IDX) + rISO.GetUniqueID() + ".ini");
|
||||
@ -1061,7 +1071,7 @@ const GameListItem * CGameListCtrl::GetSelectedISO()
|
||||
if (GetSelectedItemCount() > 1)
|
||||
SetItemState(item, 0, wxLIST_STATE_SELECTED);
|
||||
|
||||
return &m_ISOFiles[GetItemData(item)];
|
||||
return m_ISOFiles[GetItemData(item)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
|
||||
void BrowseForDirectory();
|
||||
const GameListItem *GetSelectedISO();
|
||||
const GameListItem *GetISO(int index) const;
|
||||
const GameListItem *GetISO(size_t index) const;
|
||||
|
||||
enum
|
||||
{
|
||||
@ -71,7 +71,7 @@ private:
|
||||
std::vector<int> m_FlagImageIndex;
|
||||
std::vector<int> m_PlatformImageIndex;
|
||||
std::vector<int> m_EmuStateImageIndex;
|
||||
std::vector<GameListItem> m_ISOFiles;
|
||||
std::vector<GameListItem*> m_ISOFiles;
|
||||
|
||||
// NetPlay string for the gamelist
|
||||
std::string m_gameList;
|
||||
|
@ -47,8 +47,6 @@ GameListItem::GameListItem(const std::string& _rFileName)
|
||||
, m_FileSize(0)
|
||||
, m_Valid(false)
|
||||
, m_BlobCompressed(false)
|
||||
, m_pImage(NULL)
|
||||
, m_ImageSize(0)
|
||||
{
|
||||
if (LoadFromCache())
|
||||
{
|
||||
@ -100,9 +98,8 @@ GameListItem::GameListItem(const std::string& _rFileName)
|
||||
pBannerLoader->GetDescription(m_Description);
|
||||
if (pBannerLoader->GetBanner(g_ImageTemp))
|
||||
{
|
||||
m_ImageSize = DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT * 3;
|
||||
//use malloc(), since wxImage::Create below calls free() afterwards.
|
||||
m_pImage = (u8*)malloc(m_ImageSize);
|
||||
// resize vector to image size
|
||||
m_pImage.resize(DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT * 3);
|
||||
|
||||
for (size_t i = 0; i < DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT; i++)
|
||||
{
|
||||
@ -124,14 +121,14 @@ GameListItem::GameListItem(const std::string& _rFileName)
|
||||
|
||||
// If not Gamecube, create a cache file only if we have an image.
|
||||
// Wii isos create their images after you have generated the first savegame
|
||||
if (m_Platform == GAMECUBE_DISC || m_pImage)
|
||||
if (m_Platform == GAMECUBE_DISC || !m_pImage.empty())
|
||||
SaveToCache();
|
||||
}
|
||||
}
|
||||
|
||||
if (m_pImage)
|
||||
if (!m_pImage.empty())
|
||||
{
|
||||
m_Image.Create(DVD_BANNER_WIDTH, DVD_BANNER_HEIGHT, m_pImage);
|
||||
m_Image.Create(DVD_BANNER_WIDTH, DVD_BANNER_HEIGHT, &m_pImage[0], true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -173,7 +170,7 @@ void GameListItem::DoState(PointerWrap &p)
|
||||
p.Do(m_VolumeSize);
|
||||
p.Do(m_Country);
|
||||
p.Do(m_BlobCompressed);
|
||||
p.DoBuffer(&m_pImage, m_ImageSize);
|
||||
p.Do(m_pImage);
|
||||
p.Do(m_Platform);
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
#endif
|
||||
|
||||
class PointerWrap;
|
||||
class GameListItem
|
||||
class GameListItem : NonCopyable
|
||||
{
|
||||
public:
|
||||
GameListItem(const std::string& _rFileName);
|
||||
@ -78,7 +78,7 @@ private:
|
||||
#endif
|
||||
bool m_Valid;
|
||||
bool m_BlobCompressed;
|
||||
u8* m_pImage;
|
||||
std::vector<u8> m_pImage;
|
||||
u32 m_ImageSize;
|
||||
|
||||
bool LoadFromCache();
|
||||
|
Reference in New Issue
Block a user