Skip to content

Commit

Permalink
Fixes two memory leaks, which caused the scraper to crash after a whi…
Browse files Browse the repository at this point in the history
…le. 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.
  • Loading branch information
deadbeef84 committed Feb 9, 2015
1 parent 721b02c commit 1e320b7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions es-core/src/AsyncHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class AsyncHandle
{
public:
AsyncHandle() : mStatus(ASYNC_IN_PROGRESS) {};
virtual ~AsyncHandle() {};

virtual void update() = 0;

Expand Down
9 changes: 9 additions & 0 deletions es-core/src/components/NinePatchComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions es-core/src/components/NinePatchComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 1e320b7

Please sign in to comment.