summaryrefslogtreecommitdiff
path: root/chart2/source/view/main
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-10-20 14:56:32 +0200
committerMichael Stahl <mstahl@redhat.com>2014-10-20 17:14:26 +0200
commit908d1b6e632922a6fa59385c49828be3c3eeb969 (patch)
tree8748baf657b16dacc90c23696412dc9d4d274fe2 /chart2/source/view/main
parentae218f4895082ea9fca8f414a332bcf47045ba8c (diff)
chart2: fix memory leak due to cyclic reference in VAxisBase
The VAxisBase::m_xNumberFormatsSupplier refers to the ChartModel itself, and apparently that is a cyclic reference. Naively using the ChartModel's m_xNumberFormatsSupplier in ChartView::impl_createDiagramAndContent() because it will later be passed to AxisHelper::getExplicitNumberFormatKeyForAxis(), which expects to be able to convert it to a ChartModel. Since passing around the ChartModel as an XNumberFormattingSupplier is sort of un-intuitive anyway, refactor some methods to use XChartDocument instead, and only create the VPolarAxis / VCartesianAxis with the ChartModel's m_xNumberFormatsSupplier. The drawback is that if ChartModel::attachNumberFormatsSupplier() is called after ChartView::update() has created the axes, it may not have an effect on them; not sure if that is a real or hypothetical problem. Change-Id: Ib5f0d5882b85adaf44f80e086f19178b3e64882f
Diffstat (limited to 'chart2/source/view/main')
-rw-r--r--chart2/source/view/main/ChartView.cxx10
1 files changed, 6 insertions, 4 deletions
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 4ba924b88654..63ba12abda30 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -1515,7 +1515,9 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( const CreateShapeParam2D
SeriesPlottersType& rSeriesPlotterList = rParam.mpSeriesPlotterContainer->getSeriesPlotterList();
//create VAxis, so they can give necessary information for automatic scaling
- uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( static_cast< ::cppu::OWeakObject* >( &mrChartModel ), uno::UNO_QUERY );
+ uno::Reference<chart2::XChartDocument> const xChartDoc(&mrChartModel);
+ uno::Reference<util::XNumberFormatsSupplier> const xNumberFormatsSupplier(
+ mrChartModel.getNumberFormatsSupplier());
size_t nC = 0;
for( nC=0; nC < rVCooSysList.size(); nC++)
{
@@ -1529,7 +1531,7 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( const CreateShapeParam2D
pVCooSys->set3DWallPositions( eLeftWallPos, eBackWallPos, eBottomPos );
}
- pVCooSys->createVAxisList(xNumberFormatsSupplier, rPageSize, rParam.maRemainingSpace);
+ pVCooSys->createVAxisList(xChartDoc, rPageSize, rParam.maRemainingSpace);
}
// - prepare list of all axis and how they are used
@@ -1946,9 +1948,9 @@ bool lcl_getPropertySwapXAndYAxis( const uno::Reference< XDiagram >& xDiagram )
sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForAxis(
const Reference< chart2::XAxis >& xAxis
, const Reference< chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem
- , const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier )
+ , const Reference<chart2::XChartDocument>& xChartDoc)
{
- return AxisHelper::getExplicitNumberFormatKeyForAxis( xAxis, xCorrespondingCoordinateSystem, xNumberFormatsSupplier
+ return AxisHelper::getExplicitNumberFormatKeyForAxis( xAxis, xCorrespondingCoordinateSystem, xChartDoc
, true /*bSearchForParallelAxisIfNothingIsFound*/ );
}