Fix multiple free after merging multiple request objects

This commit is contained in:
Simon Robertshaw
2013-03-14 12:10:56 +00:00
parent 9ab70756af
commit 6b68c04cd6
2 changed files with 6 additions and 3 deletions

View File

@@ -115,11 +115,14 @@ RequestBroker::ProcessResponse ImageRequest::Process(RequestBroker & rb)
{ {
//Create a copy, to seperate from the cache //Create a copy, to seperate from the cache
std::vector<Request *> children(Children.begin(), Children.end());
Children.clear();
VideoBuffer * myVB = new VideoBuffer(*image); VideoBuffer * myVB = new VideoBuffer(*image);
myVB->Resize(Width, Height, true); myVB->Resize(Width, Height, true);
ResultObject = (void*)myVB; ResultObject = (void*)myVB;
rb.requestComplete(this); rb.requestComplete(this);
for(std::vector<Request*>::iterator childIter = Children.begin(), childEnd = Children.end(); childIter != childEnd; ++childIter) for(std::vector<Request*>::iterator childIter = children.begin(), childEnd = children.end(); childIter != childEnd; ++childIter)
{ {
if((*childIter)->Type == Request::Image) if((*childIter)->Type == Request::Image)
{ {

View File

@@ -9,6 +9,7 @@
#include "ImageRequest.h" #include "ImageRequest.h"
#include "client/Client.h" #include "client/Client.h"
#include "client/GameSave.h" #include "client/GameSave.h"
#include "graphics/Graphics.h"
//Asynchronous Thumbnail render & request processing //Asynchronous Thumbnail render & request processing
@@ -139,8 +140,6 @@ void RequestBroker::FlushThumbQueue()
{ {
if(CheckRequestListener(completeQueue.front()->Listener)) if(CheckRequestListener(completeQueue.front()->Listener))
{ {
std::cout << typeid(*this).name() << " Calling listener: " << completeQueue.front()->Listener.second << std::endl;
std::cout.flush();
completeQueue.front()->Listener.second->OnResponseReady(completeQueue.front()->ResultObject); completeQueue.front()->Listener.second->OnResponseReady(completeQueue.front()->ResultObject);
} }
else else
@@ -288,6 +287,7 @@ RequestBroker::Request::~Request()
delete (*iter); delete (*iter);
iter++; iter++;
} }
Children.empty();
} }
void RequestBroker::Request::Cleanup() void RequestBroker::Request::Cleanup()
{ {