diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-07-04 14:53:42 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2014-07-04 15:06:12 +0200 |
commit | 6cad548ee21f19b816726a03995b9bc8905757f8 (patch) | |
tree | 8a65c29459ac7f9ba55516fcd7292594a9a9a24d /chart2/source/model | |
parent | 1c6bd2c40fd03ec735fd6dbec01520f10ee1d55a (diff) |
chart2: add some locking to chart::ChartType UNO service
On the libreoffice-4-3 branch, chart2_unoapi crashed with what looks
like a corrupted ChartType::m_aDataSeries triggering STL assertions.
Try to protect the mutable members with SolarMutex guards.
Change-Id: I3f2edd36b8ecf37ef60239415f70abfc8b59244d
Diffstat (limited to 'chart2/source/model')
-rw-r--r-- | chart2/source/model/template/ChartType.cxx | 24 | ||||
-rw-r--r-- | chart2/source/model/template/ChartType.hxx | 7 |
2 files changed, 27 insertions, 4 deletions
diff --git a/chart2/source/model/template/ChartType.cxx b/chart2/source/model/template/ChartType.cxx index 0ead037fcb4e..9ab9722615ad 100644 --- a/chart2/source/model/template/ChartType.cxx +++ b/chart2/source/model/template/ChartType.cxx @@ -26,6 +26,7 @@ #include "CloneHelper.hxx" #include "AxisIndexDefines.hxx" #include "ContainerHelper.hxx" +#include <vcl/svapp.hxx> #include <com/sun/star/chart2/AxisType.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> @@ -56,7 +57,11 @@ ChartType::ChartType( const ChartType & rOther ) : m_xContext( rOther.m_xContext ), m_bNotifyChanges( true ) { - CloneHelper::CloneRefVector< Reference< chart2::XDataSeries > >( rOther.m_aDataSeries, m_aDataSeries ); + { + SolarMutexGuard g; // access to rOther.m_aDataSeries + CloneHelper::CloneRefVector<Reference<chart2::XDataSeries> >( + rOther.m_aDataSeries, m_aDataSeries); + } ModifyListenerHelper::addListenerToAllElements( m_aDataSeries, m_xModifyEventForwarder ); } @@ -145,6 +150,8 @@ void SAL_CALL ChartType::addDataSeries( const Reference< chart2::XDataSeries >& throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception) { + SolarMutexGuard g; + impl_addDataSeriesWithoutNotification( xDataSeries ); fireModifyEvent(); } @@ -156,6 +163,8 @@ void SAL_CALL ChartType::removeDataSeries( const Reference< chart2::XDataSeries if( !xDataSeries.is()) throw container::NoSuchElementException(); + SolarMutexGuard g; + tDataSeriesContainerType::iterator aIt( ::std::find( m_aDataSeries.begin(), m_aDataSeries.end(), xDataSeries ) ); @@ -172,6 +181,8 @@ void SAL_CALL ChartType::removeDataSeries( const Reference< chart2::XDataSeries Sequence< Reference< chart2::XDataSeries > > SAL_CALL ChartType::getDataSeries() throw (uno::RuntimeException, std::exception) { + SolarMutexGuard g; + return ContainerHelper::ContainerToSequence( m_aDataSeries ); } @@ -179,6 +190,8 @@ void SAL_CALL ChartType::setDataSeries( const Sequence< Reference< chart2::XData throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception) { + SolarMutexGuard g; + m_bNotifyChanges = false; try { @@ -304,7 +317,14 @@ void ChartType::firePropertyChangeEvent() void ChartType::fireModifyEvent() { - if( m_bNotifyChanges ) + bool bNotifyChanges; + + { + SolarMutexGuard g; + bNotifyChanges = m_bNotifyChanges; + } + + if (bNotifyChanges) m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this ))); } diff --git a/chart2/source/model/template/ChartType.hxx b/chart2/source/model/template/ChartType.hxx index 18dfaea03ba4..7facd15af85e 100644 --- a/chart2/source/model/template/ChartType.hxx +++ b/chart2/source/model/template/ChartType.hxx @@ -140,7 +140,8 @@ protected: DECLARE_XTYPEPROVIDER() protected: - ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > m_xModifyEventForwarder; + ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > + const m_xModifyEventForwarder; private: void impl_addDataSeriesWithoutNotification( @@ -149,13 +150,15 @@ private: private: ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > - m_xContext; + const m_xContext; typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > > tDataSeriesContainerType; + // --- mutable members: the following members need mutex guard --- + tDataSeriesContainerType m_aDataSeries; bool m_bNotifyChanges; |