summaryrefslogtreecommitdiff
path: root/ivi-layermanagement-examples
diff options
context:
space:
mode:
authorMichael Rodin <mrodin@de.adit-jv.com>2018-11-19 16:07:51 +0100
committerMichael Rodin <mrodin@de.adit-jv.com>2018-11-27 16:51:39 +0100
commit019011a47bfe839c6dae84489f19e187866aa06f (patch)
tree4cb0c6676275efafa5a9dd2637567ab4d2ca0392 /ivi-layermanagement-examples
parentf86999f99065e9cccd0741c79fb4053d440ad122 (diff)
downloadwayland-ivi-extension-019011a47bfe839c6dae84489f19e187866aa06f.tar.gz
EGLWLMockNavigation: class MockNavi: add code for deallocation of shader objects
Add code for deallocation of ShaderTexture and ShaderLighting objects in the destructor of MockNavi. The possible memory leak was reported by the static analyzer scan-build. Signed-off-by: Michael Rodin <mrodin@de.adit-jv.com>
Diffstat (limited to 'ivi-layermanagement-examples')
-rw-r--r--ivi-layermanagement-examples/EGLWLMockNavigation/include/MockNavi.h5
-rw-r--r--ivi-layermanagement-examples/EGLWLMockNavigation/src/MockNavi.cpp12
2 files changed, 13 insertions, 4 deletions
diff --git a/ivi-layermanagement-examples/EGLWLMockNavigation/include/MockNavi.h b/ivi-layermanagement-examples/EGLWLMockNavigation/include/MockNavi.h
index 438194d..118f38f 100644
--- a/ivi-layermanagement-examples/EGLWLMockNavigation/include/MockNavi.h
+++ b/ivi-layermanagement-examples/EGLWLMockNavigation/include/MockNavi.h
@@ -23,6 +23,8 @@
#include "IRenderable.h"
#include "IUpdateable.h"
#include "Camera.h"
+#include "ShaderLighting.h"
+#include "ShaderTexture.h"
#include <list>
using std::list;
@@ -33,6 +35,7 @@ class MockNavi : public OpenGLES2App
{
public:
MockNavi(float fps, float animationSpeed, SurfaceConfiguration* config);
+ ~MockNavi();
virtual void update(int currentTimeInMs, int lastFrameTime);
virtual void render();
@@ -45,6 +48,8 @@ private:
int m_houseCount;
list<IRenderable*> m_renderList;
list<IUpdateable*> m_updateList;
+ ShaderLighting* pShader = nullptr;
+ ShaderTexture* pShaderTexture = nullptr;
};
#endif /* _MOCKNAVI_H */
diff --git a/ivi-layermanagement-examples/EGLWLMockNavigation/src/MockNavi.cpp b/ivi-layermanagement-examples/EGLWLMockNavigation/src/MockNavi.cpp
index 66e6863..63ed3d3 100644
--- a/ivi-layermanagement-examples/EGLWLMockNavigation/src/MockNavi.cpp
+++ b/ivi-layermanagement-examples/EGLWLMockNavigation/src/MockNavi.cpp
@@ -23,8 +23,6 @@
#include "Street.h"
#include "Ground.h"
#include "Car.h"
-#include "ShaderLighting.h"
-#include "ShaderTexture.h"
#include <stdlib.h>
#include <unistd.h>
@@ -40,6 +38,12 @@ MockNavi::MockNavi(float fps, float animationSpeed, SurfaceConfiguration* config
generateCity();
}
+MockNavi::~MockNavi()
+{
+ delete pShader;
+ delete pShaderTexture;
+}
+
void MockNavi::update(int currentTimeInMs, int lastFrameTime)
{
m_camera.update(currentTimeInMs, lastFrameTime);
@@ -69,8 +73,8 @@ void MockNavi::render()
void MockNavi::generateCity()
{
float* projection = m_camera.getViewProjectionMatrix();
- ShaderLighting* pShader = new ShaderLighting(projection);
- ShaderTexture* pShaderTexture = new ShaderTexture(projection);
+ pShader = new ShaderLighting(projection);
+ pShaderTexture = new ShaderTexture(projection);
TextureLoader* carTexture = new TextureLoader;
bool carTextureLoaded = carTexture->loadBMP("/usr/share/wayland-ivi-extension/textures/car.bmp");
TextureLoader* streetTexture = new TextureLoader;