[Libreoffice-commits] core.git: Branch 'feature/chart-3d-chart2' - 5 commits - chart2/source include/vcl vcl/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Thu May 22 18:03:21 PDT 2014
chart2/source/view/charttypes/GL3DBarChart.cxx | 14 ++++++++++++--
chart2/source/view/inc/GL3DBarChart.hxx | 2 ++
chart2/source/view/main/GL3DRenderer.cxx | 19 +++++++++++++++++++
include/vcl/opengl/OpenGLContext.hxx | 2 ++
include/vcl/openglwin.hxx | 2 ++
vcl/source/opengl/OpenGLContext.cxx | 7 +++++++
vcl/source/opengl/OpenGLHelper.cxx | 6 +++---
vcl/source/window/openglwin.cxx | 2 ++
8 files changed, 49 insertions(+), 5 deletions(-)
New commits:
commit 032df92ebcb59cc614b703073fdb5f31aa8570fc
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri May 23 02:11:23 2014 +0200
Lsan: fix memory leak
Change-Id: I82a517a267cceaac4dd1030d45c67fc070e22def
diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index a9df966..ed2a6c7 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -137,6 +137,8 @@ struct GLWindow
bMultiSampleSupported(false)
{
}
+
+ ~GLWindow();
};
class VCLOPENGL_DLLPUBLIC OpenGLContext
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 4128bf4..e07b341 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -19,6 +19,13 @@
using namespace com::sun::star;
+GLWindow::~GLWindow()
+{
+#if defined( UNX )
+ XFree(vi);
+#endif
+}
+
OpenGLContext::OpenGLContext():
mpWindow(NULL),
m_pChildWindow(NULL),
commit 7410d9f8f0d927825ce8820ff8e3afc66c739fb5
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri May 23 02:01:03 2014 +0200
Lsan: fix memory leak
Change-Id: Id8adb7517960a33f9900cb773b62b84db71e795a
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index 50d5799..bace47b 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -38,14 +38,14 @@ OString loadShader(const OUString& rFilename)
{
sal_uInt64 nSize = 0;
aFile.getSize(nSize);
- char* content = new char[nSize+1];
+ boost::scoped_array<char> content(new char[nSize+1]);
sal_uInt64 nBytesRead = 0;
- aFile.read(content, nSize, nBytesRead);
+ aFile.read(content.get(), nSize, nBytesRead);
if(nSize != nBytesRead)
assert(false);
content[nSize] = 0;
- return OString(content);
+ return OString(content.get());
}
else
{
commit 640bdf827d45425b07e53bcb1eb223ebd45aea9f
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri May 23 01:58:41 2014 +0200
Lsan: fix memory leaks
Change-Id: I010c7c194bf0680a499077b6b364498a09542764
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 7cec6af..e5e08d3 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -873,6 +873,8 @@ void OpenGL3DRenderer::RenderPolygon3DObject()
polygon.verticesList.end(), DeletePointer<Vertices3D>());
std::for_each(polygon.normalsList.begin(),
polygon.normalsList.end(), DeletePointer<Normals3D>());
+ delete polygon.vertices;
+ delete polygon.normals;
m_Polygon3DInfoList.pop_front();
}
glDepthMask(GL_TRUE);
commit eea7e208486e57ac1ff60281c077570f1179aa47
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri May 23 01:41:49 2014 +0200
Lsan: fix memory leaks
Change-Id: I35adb022f12c6833f4f29b2e8dad44394a2c4be5
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 1f8fe41..7cec6af 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -840,6 +840,19 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
glUseProgram(0);
}
+namespace {
+
+template< typename T >
+struct DeletePointer
+{
+ void operator()(T* p)
+ {
+ delete p;
+ }
+};
+
+}
+
void OpenGL3DRenderer::RenderPolygon3DObject()
{
glDepthMask(GL_FALSE);
@@ -856,6 +869,10 @@ void OpenGL3DRenderer::RenderPolygon3DObject()
{
RenderPolygon3D(polygon);
}
+ std::for_each(polygon.verticesList.begin(),
+ polygon.verticesList.end(), DeletePointer<Vertices3D>());
+ std::for_each(polygon.normalsList.begin(),
+ polygon.normalsList.end(), DeletePointer<Normals3D>());
m_Polygon3DInfoList.pop_front();
}
glDepthMask(GL_TRUE);
commit d8af055bacfad18aebceb1be7163ef8bf5e4ff6d
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Fri May 23 01:19:19 2014 +0200
Lsan: fix invalid memory access
The chart object can be destroyed after the context.
Change-Id: I5ae370638f296ea314ee11680e0a8d81a8fdbe69
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index a3a8858..5b0c764 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -29,7 +29,8 @@ GL3DBarChart::GL3DBarChart(
mxChartType(xChartType),
mpRenderer(new opengl3D::OpenGL3DRenderer()),
mrWindow(rWindow),
- mpCamera(NULL)
+ mpCamera(NULL),
+ mbValidContext(true)
{
Size aSize = mrWindow.GetSizePixel();
mpRenderer->SetSize(aSize);
@@ -39,7 +40,8 @@ GL3DBarChart::GL3DBarChart(
GL3DBarChart::~GL3DBarChart()
{
- mrWindow.setRenderer(NULL);
+ if(mbValidContext)
+ mrWindow.setRenderer(NULL);
}
namespace {
@@ -186,6 +188,9 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
void GL3DBarChart::render()
{
+ if(!mbValidContext)
+ return;
+
mrWindow.getContext()->makeCurrent();
Size aSize = mrWindow.GetSizePixel();
mpRenderer->SetSize(aSize);
@@ -238,6 +243,11 @@ void GL3DBarChart::clickedAt(const Point& rPos)
mpCamera->zoom(nId);
}
+void GL3DBarChart::contextDestroyed()
+{
+ mbValidContext = false;
+}
+
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index cc252cf..674daf6 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -47,6 +47,7 @@ public:
virtual void update() SAL_OVERRIDE;
virtual void clickedAt(const Point& rPos) SAL_OVERRIDE;
+ virtual void contextDestroyed() SAL_OVERRIDE;
private:
css::uno::Reference<css::chart2::XChartType> mxChartType;
@@ -56,6 +57,7 @@ private:
OpenGLWindow& mrWindow;
opengl3D::Camera* mpCamera;
+ bool mbValidContext;
};
}
diff --git a/include/vcl/openglwin.hxx b/include/vcl/openglwin.hxx
index e9b823e..8e34d05 100644
--- a/include/vcl/openglwin.hxx
+++ b/include/vcl/openglwin.hxx
@@ -24,6 +24,8 @@ public:
virtual ~IRenderer() {}
virtual void update() = 0;
virtual void clickedAt(const Point& rPos) = 0;
+
+ virtual void contextDestroyed() = 0;
};
// pImpl Pattern to avoid linking against OpenGL libs when using the class without the context
diff --git a/vcl/source/window/openglwin.cxx b/vcl/source/window/openglwin.cxx
index d6fb9c4..d6e5357 100644
--- a/vcl/source/window/openglwin.cxx
+++ b/vcl/source/window/openglwin.cxx
@@ -40,6 +40,8 @@ OpenGLWindow::OpenGLWindow(Window* pParent):
OpenGLWindow::~OpenGLWindow()
{
+ if(mpRenderer)
+ mpRenderer->contextDestroyed();
}
OpenGLContext* OpenGLWindow::getContext()
More information about the Libreoffice-commits
mailing list