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

Michael Stahl mstahl at redhat.com
Fri Jul 4 06:10:57 PDT 2014


 chart2/source/model/template/ChartType.cxx |   24 ++++++++++++++++++++++--
 chart2/source/model/template/ChartType.hxx |    7 +++++--
 2 files changed, 27 insertions(+), 4 deletions(-)

New commits:
commit 6cad548ee21f19b816726a03995b9bc8905757f8
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Jul 4 14:53:42 2014 +0200

    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

diff --git a/chart2/source/model/template/ChartType.cxx b/chart2/source/model/template/ChartType.cxx
index 0ead037..9ab9722 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 18dfaea..7facd15 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;


More information about the Libreoffice-commits mailing list