[Libreoffice-commits] core.git: 8 commits - chart2/source formula/source include/vcl vcl/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Thu May 22 17:56:00 PDT 2014
chart2/source/view/charttypes/GL3DBarChart.cxx | 14 ++++++++++++--
chart2/source/view/inc/GL3DBarChart.hxx | 2 ++
chart2/source/view/inc/GL3DRenderer.hxx | 1 -
chart2/source/view/main/GL3DRenderer.cxx | 19 +++++++++++++++++++
formula/source/ui/dlg/funcpage.cxx | 11 ++++-------
include/vcl/opengl/OpenGLContext.hxx | 6 ++++--
include/vcl/openglwin.hxx | 2 ++
vcl/source/opengl/OpenGLContext.cxx | 7 +++++++
vcl/source/opengl/OpenGLHelper.cxx | 6 +++---
vcl/source/window/openglwin.cxx | 2 ++
10 files changed, 55 insertions(+), 15 deletions(-)
New commits:
commit e44e09c400164e1f18aecfc67fbcae44a300b714
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri May 23 02:24:56 2014 +0200
whitespace clean-up
Change-Id: I10bdfc3356bda66fefa59fa2c9f63f9231d8728e
diff --git a/formula/source/ui/dlg/funcpage.cxx b/formula/source/ui/dlg/funcpage.cxx
index dd21c15..252e461 100644
--- a/formula/source/ui/dlg/funcpage.cxx
+++ b/formula/source/ui/dlg/funcpage.cxx
@@ -57,10 +57,6 @@ bool FormulaListBox::PreNotify( NotifyEvent& rNEvt )
return nResult;
}
-
-
-
-
inline sal_uInt16 Lb2Cat( sal_uInt16 nLbPos )
{
// Category 0 == LRU, otherwise Categories == LbPos-1
@@ -70,8 +66,6 @@ inline sal_uInt16 Lb2Cat( sal_uInt16 nLbPos )
return nLbPos;
}
-
-
FuncPage::FuncPage(Window* pParent,const IFunctionManager* _pFunctionManager):
TabPage(pParent,ModuleRes(RID_FORMULATAB_FUNCTION)),
aFtCategory ( this, ModuleRes( FT_CATEGORY ) ),
@@ -108,7 +102,7 @@ void FuncPage::impl_addFunctions(const IFunctionCategory* _pCategory)
TFunctionDesc pDesc(_pCategory->getFunction(i));
aLbFunction.SetEntryData(
aLbFunction.InsertEntry(pDesc->getFunctionName() ),(void*)pDesc );
- } // for(sal_uInt32 i = 0 ; i < nCount; ++i)
+ }
}
void FuncPage::UpdateFunctionList()
@@ -194,10 +188,12 @@ void FuncPage::SetCategory(sal_Int32 nCat)
aLbCategory.SelectEntryPos(nCat);
UpdateFunctionList();
}
+
sal_Int32 FuncPage::GetFuncPos(const IFunctionDescription* _pDesc)
{
return aLbFunction.GetEntryPos(_pDesc);
}
+
void FuncPage::SetFunction(sal_Int32 nFunc)
{
aLbFunction.SelectEntryPos(nFunc);
@@ -227,6 +223,7 @@ OUString FuncPage::GetSelFunctionName() const
{
return aLbFunction.GetSelectEntry();
}
+
const IFunctionDescription* FuncPage::GetFuncDesc( sal_Int32 nPos ) const
{
// not pretty, but hopefully rare
commit e4ee3dd1dc062e0ed7681f499618a6a9069b8d25
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri May 23 02:13:28 2014 +0200
we only support GLX 1.3+
Change-Id: I2447498cf92da91a7fb2d67ee041d603ae16fe25
diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index bceb8ff..608c9cb 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -96,7 +96,7 @@ struct GLWindow
Display* dpy;
int screen;
XLIB_Window win;
-#if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap )
+#if defined( GLX_EXT_texture_from_pixmap )
GLXFBConfig fbc;
#endif
XVisualInfo* vi;
@@ -123,7 +123,7 @@ struct GLWindow
dpy(NULL),
screen(0),
win(0),
-#if defined( GLX_VERSION_1_3 ) && defined( GLX_EXT_texture_from_pixmap )
+#if defined( GLX_EXT_texture_from_pixmap )
fbc(0),
#endif
vi(NULL),
commit cfaa96546aa0fe347ee169f411d45370eb21810a
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 7c233c9..bceb8ff 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 fb3bd72..cba0b52 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 a1e7915bfec4b9e006a0fc4c6819b63b139af2f0
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 5b37884d57398d4c11524f6d1ec92e032bb46d40
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 a42220e..8c0b449 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 68c1977ce04d41579e07b44b4612d35566807dbc
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri May 23 01:44:58 2014 +0200
remove unused variable
Change-Id: Ib79f0c525608d279eebe820bfc82e84dd3518c29
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index c2d7b87..6943012 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -84,7 +84,6 @@ struct Polygon3DInfo
UVs3D *uvs;
Normals3D *normals;
std::list <Vertices3D *> verticesList;
- std::list <UVs3D *> uvsList;
std::list <Normals3D *> normalsList;
MaterialParameters material;
};
commit 3bb9a29081b31ef4e68da9b648742e6874c393ff
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 d6c1dff..a42220e 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 2b2fc70d2626a978b9593a04a234565c9abb26e7
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