diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-07-04 14:53:42 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-07-07 22:42:57 +0000 |
commit | 30d5ee596d725377cec38cfc99e5d5891b42b35d (patch) | |
tree | debf6a4f4ec619eb0660046ebe170b241a70a857 /chart2 | |
parent | 933545f9bee6ed8d791ee4026cc0986702417ed8 (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
(cherry picked from commit 6cad548ee21f19b816726a03995b9bc8905757f8)
Reviewed-on: https://gerrit.libreoffice.org/10085
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'chart2')
-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 9fb275f7a61e..ea1f5ab3223b 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 ); } @@ -150,6 +155,8 @@ void SAL_CALL ChartType::addDataSeries( const Reference< chart2::XDataSeries >& throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception) { + SolarMutexGuard g; + impl_addDataSeriesWithoutNotification( xDataSeries ); fireModifyEvent(); } @@ -161,6 +168,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 ) ); @@ -177,6 +186,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 ); } @@ -184,6 +195,8 @@ void SAL_CALL ChartType::setDataSeries( const Sequence< Reference< chart2::XData throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception) { + SolarMutexGuard g; + m_bNotifyChanges = false; try { @@ -309,7 +322,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 82eb80332504..a4c84732f2b7 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; |