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

Stephan Bergmann sbergman at redhat.com
Wed Feb 26 14:19:13 PST 2014


 chart2/source/model/main/DataSeries.cxx |   62 ++++++++------------------------
 1 file changed, 17 insertions(+), 45 deletions(-)

New commits:
commit 4ea1b80c4882e8746bf5a1e6ce13686c746fffaa
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Feb 26 23:15:25 2014 +0100

    Statics with non-trivial initialization must use StaticWithInit
    
    ...not StaticAggregate, as StaticAggregate does the initialization with
    osl::GetGlobalMutex locked and can thus lead to deadlock.
    
    Change-Id: I0cce0da84b5a277fdda1ebaaeba85b04011f5459

diff --git a/chart2/source/model/main/DataSeries.cxx b/chart2/source/model/main/DataSeries.cxx
index d937011..65dba5e 100644
--- a/chart2/source/model/main/DataSeries.cxx
+++ b/chart2/source/model/main/DataSeries.cxx
@@ -43,41 +43,24 @@ using ::osl::MutexGuard;
 namespace
 {
 
-struct StaticDataSeriesDefaults_Initializer
+struct StaticDataSeriesDefaults : public rtl::StaticWithInit< ::chart::tPropertyValueMap, StaticDataSeriesDefaults >
 {
-    ::chart::tPropertyValueMap* operator()()
+    ::chart::tPropertyValueMap operator()()
     {
-        static ::chart::tPropertyValueMap aStaticDefaults;
-        lcl_AddDefaultsToMap( aStaticDefaults );
-        return &aStaticDefaults;
-    }
-private:
-    void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
-    {
-        ::chart::DataSeriesProperties::AddDefaultsToMap( rOutMap );
-        ::chart::CharacterProperties::AddDefaultsToMap( rOutMap );
-
+        ::chart::tPropertyValueMap aStaticDefaults;
+        ::chart::DataSeriesProperties::AddDefaultsToMap( aStaticDefaults );
+        ::chart::CharacterProperties::AddDefaultsToMap( aStaticDefaults );
         float fDefaultCharHeight = 10.0;
-        ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
-        ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
-        ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
+        ::chart::PropertyHelper::setPropertyValue( aStaticDefaults, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
+        ::chart::PropertyHelper::setPropertyValue( aStaticDefaults, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
+        ::chart::PropertyHelper::setPropertyValue( aStaticDefaults, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
+        return aStaticDefaults;
     }
 };
 
-struct StaticDataSeriesDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticDataSeriesDefaults_Initializer >
-{
-};
-
-struct StaticDataSeriesInfoHelper_Initializer
+struct StaticDataSeriesInfoHelper : public rtl::StaticWithInit< ::cppu::OPropertyArrayHelper, StaticDataSeriesInfoHelper, StaticDataSeriesInfoHelper, uno::Sequence< Property > >
 {
-    ::cppu::OPropertyArrayHelper* operator()()
-    {
-        static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
-        return &aPropHelper;
-    }
-
-private:
-    uno::Sequence< Property > lcl_GetPropertySequence()
+    uno::Sequence< Property > operator()()
     {
         ::std::vector< ::com::sun::star::beans::Property > aProperties;
         ::chart::DataSeriesProperties::AddPropertiesToVector( aProperties );
@@ -89,27 +72,16 @@ private:
 
         return ::chart::ContainerHelper::ContainerToSequence( aProperties );
     }
-
-};
-
-struct StaticDataSeriesInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticDataSeriesInfoHelper_Initializer >
-{
 };
 
-struct StaticDataSeriesInfo_Initializer
+struct StaticDataSeriesInfo : public rtl::StaticWithInit< uno::Reference< beans::XPropertySetInfo >, StaticDataSeriesInfo >
 {
-    uno::Reference< beans::XPropertySetInfo >* operator()()
+    uno::Reference< beans::XPropertySetInfo > operator()()
     {
-        static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
-            ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticDataSeriesInfoHelper::get() ) );
-        return &xPropertySetInfo;
+        return ::cppu::OPropertySetHelper::createPropertySetInfo(StaticDataSeriesInfoHelper::get() );
     }
 };
 
-struct StaticDataSeriesInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticDataSeriesInfo_Initializer >
-{
-};
-
 void lcl_SetParent(
     const uno::Reference< uno::XInterface > & xChildInterface,
     const uno::Reference< uno::XInterface > & xParentInterface )
@@ -273,7 +245,7 @@ Sequence< OUString > DataSeries::getSupportedServiceNames_Static()
 uno::Any DataSeries::GetDefaultValue( sal_Int32 nHandle ) const
     throw(beans::UnknownPropertyException)
 {
-    const tPropertyValueMap& rStaticDefaults = *StaticDataSeriesDefaults::get();
+    const tPropertyValueMap& rStaticDefaults = StaticDataSeriesDefaults::get();
     tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
     if( aFound == rStaticDefaults.end() )
         return uno::Any();
@@ -283,14 +255,14 @@ uno::Any DataSeries::GetDefaultValue( sal_Int32 nHandle ) const
 // ____ OPropertySet ____
 ::cppu::IPropertyArrayHelper & SAL_CALL DataSeries::getInfoHelper()
 {
-    return *StaticDataSeriesInfoHelper::get();
+    return StaticDataSeriesInfoHelper::get();
 }
 
 // ____ XPropertySet ____
 uno::Reference< beans::XPropertySetInfo > SAL_CALL DataSeries::getPropertySetInfo()
     throw (uno::RuntimeException, std::exception)
 {
-    return *StaticDataSeriesInfo::get();
+    return StaticDataSeriesInfo::get();
 }
 
 void SAL_CALL DataSeries::getFastPropertyValue


More information about the Libreoffice-commits mailing list