Fixes two memory leaks, which caused the scraper to crash after a while. I believe this fixes #180.

Fixes #352 (duplicate).
Fixes #362 (duplicate).

The destructor for AsyncHandle needs to be virtual as its subclasses are
allocated dynamically. I believe this caused the ImageDownloadHandle and its
related resources (such as the HttpReq and its contents) not to be freed
correctly.
This commit is contained in:
Jesper Ek 2015-02-09 23:23:36 +01:00
parent 721b02cfab
commit 1e320b7718
3 changed files with 11 additions and 0 deletions

View file

@ -12,6 +12,7 @@ class AsyncHandle
{
public:
AsyncHandle() : mStatus(ASYNC_IN_PROGRESS) {};
virtual ~AsyncHandle() {};
virtual void update() = 0;

View file

@ -14,6 +14,15 @@ NinePatchComponent::NinePatchComponent(Window* window, const std::string& path,
buildVertices();
}
NinePatchComponent::~NinePatchComponent()
{
if (mVertices != NULL)
delete[] mVertices;
if (mColors != NULL)
delete[] mColors;
}
void NinePatchComponent::updateColors()
{
Renderer::buildGLColorArray(mColors, mEdgeColor, 6 * 9);

View file

@ -18,6 +18,7 @@ class NinePatchComponent : public GuiComponent
{
public:
NinePatchComponent(Window* window, const std::string& path = "", unsigned int edgeColor = 0xFFFFFFFF, unsigned int centerColor = 0xFFFFFFFF);
virtual ~NinePatchComponent();
void render(const Eigen::Affine3f& parentTrans) override;