Remove 1500+ memory leaks in OpenSpace and Ghoul

This commit is contained in:
Alexander Bock
2015-05-25 19:37:56 +02:00
parent b840631813
commit 659326b9a9
17 changed files with 136 additions and 96 deletions

View File

@@ -148,12 +148,13 @@ bool RenderableModel::deinitialize() {
if (_geometry) {
_geometry->deinitialize();
delete _geometry;
_geometry = nullptr;
}
if (_texture)
delete _texture;
delete _texture;
_texture = nullptr;
_geometry = nullptr;
_texture = nullptr;
delete _programObject;
_programObject = nullptr;
return true;
}

View File

@@ -119,7 +119,14 @@ bool RenderablePath::initialize() {
bool RenderablePath::deinitialize() {
glDeleteVertexArrays(1, &_vaoID);
_vaoID = 0;
glDeleteBuffers(1, &_vBufferID);
_vBufferID = 0;
delete _programObject;
_programObject = nullptr;
return true;
}

View File

@@ -109,6 +109,7 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
RenderablePlane::~RenderablePlane() {
delete _textureFile;
_textureFile = nullptr;
}
bool RenderablePlane::isReady() const {
@@ -142,9 +143,19 @@ bool RenderablePlane::initialize() {
bool RenderablePlane::deinitialize() {
glDeleteVertexArrays(1, &_quad);
_quad = 0;
glDeleteBuffers(1, &_vertexPositionBuffer);
_vertexPositionBuffer = 0;
delete _texture;
_texture = nullptr;
delete _textureFile;
_textureFile = nullptr;
delete _shader;
_shader = nullptr;
return true;
}

View File

@@ -52,7 +52,7 @@ class RenderablePlane : public Renderable {
public:
RenderablePlane(const ghoul::Dictionary& dictionary);
~RenderablePlane();
~RenderablePlane();
bool initialize() override;
bool deinitialize() override;

View File

@@ -106,9 +106,6 @@ RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary)
_texturePath.onChange(std::bind(&RenderableSphere::loadTexture, this));
}
RenderableSphere::~RenderableSphere() {
}
bool RenderableSphere::isReady() const {
return (_sphere != nullptr) && (_shader != nullptr) && (_texture != nullptr);
}
@@ -132,7 +129,14 @@ bool RenderableSphere::initialize() {
bool RenderableSphere::deinitialize() {
delete _sphere;
_sphere = nullptr;
delete _texture;
_texture = nullptr;
delete _shader;
_shader = nullptr;
return true;
}

View File

@@ -41,7 +41,6 @@ class PowerScaledSphere;
class RenderableSphere : public Renderable {
public:
RenderableSphere(const ghoul::Dictionary& dictionary);
~RenderableSphere();
bool initialize() override;
bool deinitialize() override;

View File

@@ -137,6 +137,7 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary)
RenderableStars::~RenderableStars() {
delete _psfTextureFile;
delete _colorTextureFile;
delete _colorTexture;
}
bool RenderableStars::isReady() const {

View File

@@ -100,6 +100,10 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
_distanceFade = 1.0;
}
RenderableTrail::~RenderableTrail() {
delete _programObject;
}
bool RenderableTrail::initialize() {
if (!_successfullDictionaryFetch) {
LERROR("The following keys need to be set in the Dictionary. Cannot initialize!");

View File

@@ -43,6 +43,7 @@ namespace openspace {
class RenderableTrail : public Renderable {
public:
RenderableTrail(const ghoul::Dictionary& dictionary);
~RenderableTrail();
bool initialize() override;
bool deinitialize() override;