Fix a few small (a lot of big) memory leaks associated with the stamps browser

This commit is contained in:
Simon Robertshaw 2012-08-19 21:31:24 +01:00
parent 9dd9d52564
commit 43ed72b4c5
5 changed files with 21 additions and 4 deletions

View File

@ -813,7 +813,7 @@ SaveFile * Client::GetStamp(std::string stampID)
size_t fileSize = stampFile.tellg();
stampFile.seekg(0);
unsigned char * tempData = (unsigned char *)malloc(fileSize);
unsigned char * tempData = new unsigned char[fileSize];
stampFile.read((char *)tempData, fileSize);
stampFile.close();
@ -826,8 +826,10 @@ SaveFile * Client::GetStamp(std::string stampID)
}
catch (ParseException & e)
{
delete[] tempData;
std::cerr << "Client: Invalid stamp file, " << stampID << " " << std::string(e.what()) << std::endl;
}
delete[] tempData;
return file;
}
else

View File

@ -180,6 +180,10 @@ GameController::~GameController()
{
delete activePreview;
}
if(localBrowser)
{
delete localBrowser;
}
if(ui::Engine::Ref().GetWindow() == gameView)
{
ui::Engine::Ref().CloseWindow();
@ -751,6 +755,12 @@ void GameController::Update()
delete loginWindow;
loginWindow = NULL;
}
if(localBrowser && localBrowser->HasDone)
{
delete localBrowser;
localBrowser = NULL;
}
}
void GameController::SetZoomEnabled(bool zoomEnabled)

View File

@ -119,6 +119,8 @@ GameModel::~GameModel()
}
delete sim;
delete ren;
if(placeSave)
delete placeSave;
if(clipboard)
delete clipboard;
if(stamp)

View File

@ -527,6 +527,9 @@ GameView::~GameView()
if(!colourAValue->GetParentWindow())
delete colourAValue;
if(placeSaveThumb)
delete placeSaveThumb;
}
class GameView::MenuAction: public ui::ButtonAction

View File

@ -68,10 +68,10 @@ void LocalBrowserModel::UpdateSavesList(int pageNumber)
currentPage = pageNumber;
notifyPageChanged();
notifySavesListChanged();
/*notifyStampsListChanged();
for(int i = 0; i < tempStampsList.size(); i++)
//notifyStampsListChanged();
/*for(int i = 0; i < tempSavesList.size(); i++)
{
delete tempStampsList[i];
delete tempSavesList[i];
}*/
stampIDs = Client::Ref().GetStamps((pageNumber-1)*20, 20);