diff options
author | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2014-05-23 01:19:19 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-06-07 05:03:02 +0200 |
commit | bc0e7a03c0594fe298d277c4b0889ba55d6f5e7c (patch) | |
tree | a931dc244869fcfe5c71b92d3fb29da7e6a1728f /chart2 | |
parent | c45565b4f46ff9c5ebb4bbf5dfe09d0d77ceeec6 (diff) |
Lsan: fix invalid memory access
The chart object can be destroyed after the context.
Change-Id: I5ae370638f296ea314ee11680e0a8d81a8fdbe69
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/view/charttypes/GL3DBarChart.cxx | 14 | ||||
-rw-r--r-- | chart2/source/view/inc/GL3DBarChart.hxx | 2 |
2 files changed, 14 insertions, 2 deletions
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx index 542711a5d4fb..036939e2dd75 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 cc252cf4e014..674daf6e0d09 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; }; } |