[Libreoffice-commits] core.git: chart2/source

Kohei Yoshida kohei.yoshida at collabora.com
Thu May 8 10:11:11 PDT 2014


 chart2/source/view/charttypes/GL3DBarChart.cxx |   12 ++++++------
 chart2/source/view/inc/GL3DBarChart.hxx        |    4 ++--
 chart2/source/view/main/ChartView.cxx          |    5 ++---
 3 files changed, 10 insertions(+), 11 deletions(-)

New commits:
commit 2908bfefbc04357890967bb13a4435b9fdb643d4
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Thu May 8 13:10:45 2014 -0400

    Stop the leak of VDataSeries instances.
    
    Change-Id: I36cfa84e4fb19c3da584672d510e8b35f9343950

diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 6cd0d0a..be82ca5 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -25,7 +25,7 @@ namespace chart {
 
 GL3DBarChart::GL3DBarChart(
     const css::uno::Reference<css::chart2::XChartType>& xChartType,
-    const std::vector<VDataSeries*>& rDataSeries,
+    const boost::ptr_vector<VDataSeries>& rDataSeries,
     OpenGLWindow& rWindow, ExplicitCategoriesProvider& rCatProvider ) :
     mxChartType(xChartType),
     maDataSeries(rDataSeries),
@@ -56,22 +56,22 @@ void GL3DBarChart::create3DShapes()
     maShapes.clear();
     maShapes.push_back(new opengl3D::Camera(mpRenderer.get()));
     sal_Int32 nSeriesIndex = 0;
-    for(std::vector<VDataSeries*>::const_iterator itr = maDataSeries.begin(),
+    for (boost::ptr_vector<VDataSeries>::const_iterator itr = maDataSeries.begin(),
             itrEnd = maDataSeries.end(); itr != itrEnd; ++itr)
     {
-        VDataSeries* pDataSeries = *itr;
-        sal_Int32 nPointCount = pDataSeries->getTotalPointCount();
+        const VDataSeries& rDataSeries = *itr;
+        sal_Int32 nPointCount = rDataSeries.getTotalPointCount();
 
         // Create series name text object.
         OUString aSeriesName =
             DataSeriesHelper::getDataSeriesLabel(
-                pDataSeries->getModel(), mxChartType->getRoleOfSequenceForSeriesLabel());
+                rDataSeries.getModel(), mxChartType->getRoleOfSequenceForSeriesLabel());
 
         maShapes.push_back(new opengl3D::Text(mpRenderer.get(), aSeriesName, nId++));
 
         for(sal_Int32 nIndex = 0; nIndex < nPointCount; ++nIndex)
         {
-            float nVal = pDataSeries->getYValue(nIndex);
+            float nVal = rDataSeries.getYValue(nIndex);
             float nXPos = nIndex * (nBarSizeX + nBarDistanceX);
             float nYPos = nSeriesIndex * (nBarSizeY + nBarDistanceY);
 
diff --git a/chart2/source/view/inc/GL3DBarChart.hxx b/chart2/source/view/inc/GL3DBarChart.hxx
index f3e225f..8237805 100644
--- a/chart2/source/view/inc/GL3DBarChart.hxx
+++ b/chart2/source/view/inc/GL3DBarChart.hxx
@@ -36,7 +36,7 @@ class GL3DBarChart
 public:
     GL3DBarChart(
         const css::uno::Reference<css::chart2::XChartType>& xChartType,
-        const std::vector<VDataSeries*>& rDataSeries, OpenGLWindow& rContext,
+        const boost::ptr_vector<VDataSeries>& rDataSeries, OpenGLWindow& rContext,
         ExplicitCategoriesProvider& rCatProvider );
 
     ~GL3DBarChart();
@@ -47,7 +47,7 @@ public:
 
 private:
     css::uno::Reference<css::chart2::XChartType> mxChartType;
-    std::vector<VDataSeries*> maDataSeries;
+    const boost::ptr_vector<VDataSeries>& maDataSeries;
     boost::ptr_vector<opengl3D::Renderable3DObject> maShapes;
 
     boost::scoped_ptr<opengl3D::OpenGL3DRenderer> mpRenderer;
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 0c23d05..13f4bf7 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -3120,7 +3120,7 @@ void ChartView::createShapes3D()
         return;
 
     uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
-    std::vector<VDataSeries*> aDataSeries;
+    boost::ptr_vector<VDataSeries> aDataSeries;
 
     if (aCooSysList.getLength() != 1)
         // Supporting multiple coordinates in a truly 3D chart (which implies
@@ -3155,8 +3155,7 @@ void ChartView::createShapes3D()
         if(!xDataSeries.is())
             continue;
 
-        VDataSeries* pSeries = new VDataSeries( xDataSeries );
-        aDataSeries.push_back(pSeries);
+        aDataSeries.push_back(new VDataSeries(xDataSeries));
     }
 
     OpenGLWindow* pWindow = mrChartModel.getOpenGLWindow();


More information about the Libreoffice-commits mailing list