fix memory leaks when loading stamps ('l') and viewing saves
This commit is contained in:
parent
22b9bf4953
commit
6731fa16b7
@ -45,6 +45,7 @@ RequestBroker::ProcessResponse ImageRequest::Process(RequestBroker & rb)
|
|||||||
char * data;
|
char * data;
|
||||||
int status, data_size, imgw, imgh;
|
int status, data_size, imgw, imgh;
|
||||||
data = http_async_req_stop(HTTPContext, &status, &data_size);
|
data = http_async_req_stop(HTTPContext, &status, &data_size);
|
||||||
|
started = false;
|
||||||
|
|
||||||
if (status == 200 && data)
|
if (status == 200 && data)
|
||||||
{
|
{
|
||||||
@ -107,6 +108,7 @@ RequestBroker::ProcessResponse ImageRequest::Process(RequestBroker & rb)
|
|||||||
std::cout << typeid(*this).name() << " Creating new request for " << URL << std::endl;
|
std::cout << typeid(*this).name() << " Creating new request for " << URL << std::endl;
|
||||||
#endif*/
|
#endif*/
|
||||||
HTTPContext = http_async_req_start(NULL, (char *)URL.c_str(), NULL, 0, 0);
|
HTTPContext = http_async_req_start(NULL, (char *)URL.c_str(), NULL, 0, 0);
|
||||||
|
started = true;
|
||||||
RequestTime = time(NULL);
|
RequestTime = time(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -147,4 +149,10 @@ void ImageRequest::Cleanup()
|
|||||||
delete ((VideoBuffer*)ResultObject);
|
delete ((VideoBuffer*)ResultObject);
|
||||||
ResultObject = NULL;
|
ResultObject = NULL;
|
||||||
}
|
}
|
||||||
|
if (HTTPContext && started)
|
||||||
|
{
|
||||||
|
http_force_close(HTTPContext);
|
||||||
|
http_async_req_stop(HTTPContext, nullptr, nullptr);
|
||||||
|
started = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ public:
|
|||||||
std::string URL;
|
std::string URL;
|
||||||
int RequestTime;
|
int RequestTime;
|
||||||
void * HTTPContext;
|
void * HTTPContext;
|
||||||
|
bool started = false;
|
||||||
ImageRequest(std::string url, int width, int height, ListenerHandle listener, int identifier = 0);
|
ImageRequest(std::string url, int width, int height, ListenerHandle listener, int identifier = 0);
|
||||||
virtual RequestBroker::ProcessResponse Process(RequestBroker & rb);
|
virtual RequestBroker::ProcessResponse Process(RequestBroker & rb);
|
||||||
virtual ~ImageRequest();
|
virtual ~ImageRequest();
|
||||||
|
@ -1021,10 +1021,10 @@ void GameModel::ClearSimulation()
|
|||||||
|
|
||||||
void GameModel::SetPlaceSave(GameSave * save)
|
void GameModel::SetPlaceSave(GameSave * save)
|
||||||
{
|
{
|
||||||
if(save != placeSave)
|
if (save != placeSave)
|
||||||
{
|
{
|
||||||
delete placeSave;
|
delete placeSave;
|
||||||
if(save)
|
if (save)
|
||||||
placeSave = new GameSave(*save);
|
placeSave = new GameSave(*save);
|
||||||
else
|
else
|
||||||
placeSave = NULL;
|
placeSave = NULL;
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include "GameView.h"
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "gui/Style.h"
|
#include "Favorite.h"
|
||||||
#include "GameView.h"
|
#include "Format.h"
|
||||||
|
#include "IntroText.h"
|
||||||
|
#include "QuickOptions.h"
|
||||||
|
#include "DecorationTool.h"
|
||||||
|
#include "client/SaveFile.h"
|
||||||
#include "graphics/Graphics.h"
|
#include "graphics/Graphics.h"
|
||||||
#include "gui/interface/Window.h"
|
#include "gui/Style.h"
|
||||||
|
#include "gui/dialogues/ConfirmPrompt.h"
|
||||||
|
#include "gui/dialogues/InformationMessage.h"
|
||||||
#include "gui/interface/Button.h"
|
#include "gui/interface/Button.h"
|
||||||
#include "gui/interface/Colour.h"
|
#include "gui/interface/Colour.h"
|
||||||
#include "gui/interface/Keys.h"
|
#include "gui/interface/Keys.h"
|
||||||
#include "gui/interface/Mouse.h"
|
#include "gui/interface/Mouse.h"
|
||||||
#include "gui/interface/Slider.h"
|
#include "gui/interface/Slider.h"
|
||||||
|
#include "gui/interface/Window.h"
|
||||||
#include "gui/search/Thumbnail.h"
|
#include "gui/search/Thumbnail.h"
|
||||||
#include "simulation/SaveRenderer.h"
|
#include "simulation/SaveRenderer.h"
|
||||||
#include "simulation/SimulationData.h"
|
#include "simulation/SimulationData.h"
|
||||||
#include "gui/dialogues/InformationMessage.h"
|
|
||||||
#include "gui/dialogues/ConfirmPrompt.h"
|
|
||||||
#include "client/SaveFile.h"
|
|
||||||
#include "Format.h"
|
|
||||||
#include "QuickOptions.h"
|
|
||||||
#include "IntroText.h"
|
|
||||||
#include "DecorationTool.h"
|
|
||||||
#include "Favorite.h"
|
|
||||||
|
|
||||||
|
|
||||||
class SplitButton;
|
class SplitButton;
|
||||||
@ -1612,7 +1612,9 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
|||||||
std::vector<std::string> stampList = Client::Ref().GetStamps(0, 1);
|
std::vector<std::string> stampList = Client::Ref().GetStamps(0, 1);
|
||||||
if (stampList.size())
|
if (stampList.size())
|
||||||
{
|
{
|
||||||
c->LoadStamp(Client::Ref().GetStamp(stampList[0])->GetGameSave());
|
SaveFile *saveFile = Client::Ref().GetStamp(stampList[0]);
|
||||||
|
c->LoadStamp(saveFile->GetGameSave());
|
||||||
|
delete saveFile;
|
||||||
selectPoint1 = selectPoint2 = mousePosition;
|
selectPoint1 = selectPoint2 = mousePosition;
|
||||||
isMouseDown = false;
|
isMouseDown = false;
|
||||||
break;
|
break;
|
||||||
|
@ -307,6 +307,7 @@ void PreviewModel::Update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
saveDataDownload = NULL;
|
saveDataDownload = NULL;
|
||||||
|
free(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (saveInfoDownload && saveInfoDownload->CheckDone())
|
if (saveInfoDownload && saveInfoDownload->CheckDone())
|
||||||
@ -334,6 +335,7 @@ void PreviewModel::Update()
|
|||||||
observers[i]->SaveLoadingError(Client::Ref().GetLastError());
|
observers[i]->SaveLoadingError(Client::Ref().GetLastError());
|
||||||
}
|
}
|
||||||
saveInfoDownload = NULL;
|
saveInfoDownload = NULL;
|
||||||
|
free(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commentsDownload && commentsDownload->CheckDone())
|
if (commentsDownload && commentsDownload->CheckDone())
|
||||||
@ -351,6 +353,7 @@ void PreviewModel::Update()
|
|||||||
notifyCommentsPageChanged();
|
notifyCommentsPageChanged();
|
||||||
|
|
||||||
commentsDownload = NULL;
|
commentsDownload = NULL;
|
||||||
|
free(ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user