diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2023-04-01 21:09:29 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-04-01 21:57:57 +0200 |
commit | 84646117baa2ac3463a007207b6b5d1d3cf0e3ae (patch) | |
tree | d22d776c9b53da45e31b5bbdf0d10749f6caef37 /chart2 | |
parent | 383f70fa9ed0ec7acd6fbc4e921bb5b91fde4689 (diff) |
fix locking in chart::Diagram
we can't return a reference to internal state that needs to be protected by a mutex
Change-Id: I13c0128559546cc2078584fc0de818c568617b7e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149914
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/inc/Diagram.hxx | 10 | ||||
-rw-r--r-- | chart2/source/model/main/Diagram.cxx | 20 | ||||
-rw-r--r-- | chart2/source/tools/AxisHelper.cxx | 6 | ||||
-rw-r--r-- | chart2/source/tools/ChartModelHelper.cxx | 6 | ||||
-rw-r--r-- | chart2/source/view/main/SeriesPlotterContainer.cxx | 6 |
5 files changed, 31 insertions, 17 deletions
diff --git a/chart2/source/inc/Diagram.hxx b/chart2/source/inc/Diagram.hxx index 874e8e904e5d..eba06976cbbf 100644 --- a/chart2/source/inc/Diagram.hxx +++ b/chart2/source/inc/Diagram.hxx @@ -163,19 +163,15 @@ public: std::vector< rtl::Reference< ::chart::BaseCoordinateSystem > > tCoordinateSystemContainerType; - const tCoordinateSystemContainerType & getBaseCoordinateSystems() { return m_aCoordSystems; } + tCoordinateSystemContainerType getBaseCoordinateSystems() const; void setCoordinateSystems( const std::vector< rtl::Reference< ::chart::BaseCoordinateSystem > >& aCoordinateSystems ); - const rtl::Reference< ::chart::Legend > & getLegend2() const { return m_xLegend; } + rtl::Reference< ::chart::Legend > getLegend2() const; void setLegend(const rtl::Reference< ::chart::Legend > &); void setDataTable(const rtl::Reference<::chart::DataTable>& xNewDataTable); - - rtl::Reference<::chart::DataTable> const& getDataTableRef() const - { - return m_xDataTable; - }; + rtl::Reference<::chart::DataTable> getDataTableRef() const; DiagramPositioningMode getDiagramPositioningMode(); diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx index 1522d168c542..63bead4ef1b2 100644 --- a/chart2/source/model/main/Diagram.cxx +++ b/chart2/source/model/main/Diagram.cxx @@ -354,6 +354,12 @@ uno::Reference< chart2::XLegend > SAL_CALL Diagram::getLegend() return m_xLegend; } +rtl::Reference< ::chart::Legend > Diagram::getLegend2() const +{ + MutexGuard aGuard( m_aMutex ); + return m_xLegend; +} + void SAL_CALL Diagram::setLegend( const uno::Reference< chart2::XLegend >& xNewLegend ) { auto pLegend = dynamic_cast<Legend*>(xNewLegend.get()); @@ -606,6 +612,12 @@ uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > SAL_CALL Diagram::g return comphelper::containerToSequence<uno::Reference< chart2::XCoordinateSystem >>( m_aCoordSystems ); } +Diagram::tCoordinateSystemContainerType Diagram::getBaseCoordinateSystems() const +{ + MutexGuard aGuard( m_aMutex ); + return m_aCoordSystems; +} + void SAL_CALL Diagram::setCoordinateSystems( const Sequence< Reference< chart2::XCoordinateSystem > >& aCoordinateSystems ) { @@ -772,7 +784,13 @@ void SAL_CALL Diagram::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) co uno::Reference<chart2::XDataTable> SAL_CALL Diagram::getDataTable() { - MutexGuard aGuard(m_aMutex); + MutexGuard aGuard( m_aMutex ); + return m_xDataTable; +} + +rtl::Reference<::chart::DataTable> Diagram::getDataTableRef() const +{ + MutexGuard aGuard( m_aMutex ); return m_xDataTable; } diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx index 3fe146d259bc..7e8229352181 100644 --- a/chart2/source/tools/AxisHelper.cxx +++ b/chart2/source/tools/AxisHelper.cxx @@ -552,9 +552,9 @@ rtl::Reference< ::chart::BaseCoordinateSystem > AxisHelper::getCoordinateSystemB { if(!xDiagram.is()) return nullptr; - auto & rCooSysList = xDiagram->getBaseCoordinateSystems(); - if(0<=nIndex && o3tl::make_unsigned(nIndex) < rCooSysList.size()) - return rCooSysList[nIndex]; + auto aCooSysList = xDiagram->getBaseCoordinateSystems(); + if(0<=nIndex && o3tl::make_unsigned(nIndex) < aCooSysList.size()) + return aCooSysList[nIndex]; return nullptr; } diff --git a/chart2/source/tools/ChartModelHelper.cxx b/chart2/source/tools/ChartModelHelper.cxx index 3018797b6dca..0aa2288ff888 100644 --- a/chart2/source/tools/ChartModelHelper.cxx +++ b/chart2/source/tools/ChartModelHelper.cxx @@ -81,9 +81,9 @@ rtl::Reference< BaseCoordinateSystem > ChartModelHelper::getFirstCoordinateSyste rtl::Reference< Diagram > xDiagram = xModel->getFirstChartDiagram(); if( xDiagram.is() ) { - auto& rCooSysSeq( xDiagram->getBaseCoordinateSystems() ); - if( !rCooSysSeq.empty() ) - return rCooSysSeq[0]; + auto aCooSysSeq( xDiagram->getBaseCoordinateSystems() ); + if( !aCooSysSeq.empty() ) + return aCooSysSeq[0]; } return nullptr; } diff --git a/chart2/source/view/main/SeriesPlotterContainer.cxx b/chart2/source/view/main/SeriesPlotterContainer.cxx index de8c2c78cd4f..bcc5b0f482a3 100644 --- a/chart2/source/view/main/SeriesPlotterContainer.cxx +++ b/chart2/source/view/main/SeriesPlotterContainer.cxx @@ -180,11 +180,11 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(ChartModel& rChart //iterate through all coordinate systems uno::Reference<XColorScheme> xColorScheme(xDiagram->getDefaultColorScheme()); - auto& rCooSysList = xDiagram->getBaseCoordinateSystems(); + auto aCooSysList = xDiagram->getBaseCoordinateSystems(); sal_Int32 nGlobalSeriesIndex = 0; //for automatic symbols - for (std::size_t nCS = 0; nCS < rCooSysList.size(); ++nCS) + for (std::size_t nCS = 0; nCS < aCooSysList.size(); ++nCS) { - rtl::Reference<BaseCoordinateSystem> xCooSys(rCooSysList[nCS]); + rtl::Reference<BaseCoordinateSystem> xCooSys(aCooSysList[nCS]); VCoordinateSystem* pVCooSys = SeriesPlotterContainer::addCooSysToList(m_rVCooSysList, xCooSys, rChartModel); // Let's check whether the secondary Y axis is visible |