Use collapsed saves when using stamp browser, fix memory leak when saving stamps

This commit is contained in:
Simon Robertshaw 2012-08-21 13:30:30 +01:00
parent b6736f967e
commit b639da3692
2 changed files with 24 additions and 3 deletions

View File

@ -805,7 +805,26 @@ RequestStatus Client::UploadSave(SaveInfo & save)
SaveFile * Client::GetStamp(std::string stampID)
{
std::ifstream stampFile;
std::string stampFile = std::string(STAMPS_DIR PATH_SEP + stampID + ".stm");
if(FileExists(stampFile))
{
SaveFile * file = new SaveFile(stampID);
try
{
GameSave * tempSave = new GameSave(ReadFile(stampFile));
file->SetGameSave(tempSave);
}
catch (ParseException & e)
{
std::cerr << "Client: Invalid stamp file, " << stampID << " " << std::string(e.what()) << std::endl;
}
return file;
}
else
{
return NULL;
}
/*std::ifstream stampFile;
stampFile.open(std::string(STAMPS_DIR PATH_SEP + stampID + ".stm").c_str(), std::ios::binary);
if(stampFile.is_open())
{
@ -835,7 +854,7 @@ SaveFile * Client::GetStamp(std::string stampID)
else
{
return NULL;
}
}*/
}
void Client::DeleteStamp(std::string stampID)
@ -886,6 +905,8 @@ std::string Client::AddStamp(GameSave * saveData)
stampStream.write((const char *)gameData, gameDataLength);
stampStream.close();
delete[] gameData;
stampIDs.push_front(saveID.str());
updateStamps();

View File

@ -657,7 +657,7 @@ void GameModel::AddStamp(GameSave * save)
{
if(stamp)
delete stamp;
stamp = new GameSave(*save);
stamp = save;
Client::Ref().AddStamp(save);
}