Kaydet (Commit) 4ea1b80c authored tarafından Stephan Bergmann's avatar Stephan Bergmann

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
üst 994a3596
...@@ -43,41 +43,24 @@ using ::osl::MutexGuard; ...@@ -43,41 +43,24 @@ using ::osl::MutexGuard;
namespace namespace
{ {
struct StaticDataSeriesDefaults_Initializer struct StaticDataSeriesDefaults : public rtl::StaticWithInit< ::chart::tPropertyValueMap, StaticDataSeriesDefaults >
{ {
::chart::tPropertyValueMap* operator()() ::chart::tPropertyValueMap operator()()
{ {
static ::chart::tPropertyValueMap aStaticDefaults; ::chart::tPropertyValueMap aStaticDefaults;
lcl_AddDefaultsToMap( aStaticDefaults ); ::chart::DataSeriesProperties::AddDefaultsToMap( aStaticDefaults );
return &aStaticDefaults; ::chart::CharacterProperties::AddDefaultsToMap( aStaticDefaults );
}
private:
void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
{
::chart::DataSeriesProperties::AddDefaultsToMap( rOutMap );
::chart::CharacterProperties::AddDefaultsToMap( rOutMap );
float fDefaultCharHeight = 10.0; float fDefaultCharHeight = 10.0;
::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight ); ::chart::PropertyHelper::setPropertyValue( aStaticDefaults, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight ); ::chart::PropertyHelper::setPropertyValue( aStaticDefaults, ::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_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
return aStaticDefaults;
} }
}; };
struct StaticDataSeriesDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticDataSeriesDefaults_Initializer > struct StaticDataSeriesInfoHelper : public rtl::StaticWithInit< ::cppu::OPropertyArrayHelper, StaticDataSeriesInfoHelper, StaticDataSeriesInfoHelper, uno::Sequence< Property > >
{
};
struct StaticDataSeriesInfoHelper_Initializer
{ {
::cppu::OPropertyArrayHelper* operator()() uno::Sequence< Property > operator()()
{
static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
return &aPropHelper;
}
private:
uno::Sequence< Property > lcl_GetPropertySequence()
{ {
::std::vector< ::com::sun::star::beans::Property > aProperties; ::std::vector< ::com::sun::star::beans::Property > aProperties;
::chart::DataSeriesProperties::AddPropertiesToVector( aProperties ); ::chart::DataSeriesProperties::AddPropertiesToVector( aProperties );
...@@ -89,27 +72,16 @@ private: ...@@ -89,27 +72,16 @@ private:
return ::chart::ContainerHelper::ContainerToSequence( aProperties ); 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( return ::cppu::OPropertySetHelper::createPropertySetInfo(StaticDataSeriesInfoHelper::get() );
::cppu::OPropertySetHelper::createPropertySetInfo(*StaticDataSeriesInfoHelper::get() ) );
return &xPropertySetInfo;
} }
}; };
struct StaticDataSeriesInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticDataSeriesInfo_Initializer >
{
};
void lcl_SetParent( void lcl_SetParent(
const uno::Reference< uno::XInterface > & xChildInterface, const uno::Reference< uno::XInterface > & xChildInterface,
const uno::Reference< uno::XInterface > & xParentInterface ) const uno::Reference< uno::XInterface > & xParentInterface )
...@@ -273,7 +245,7 @@ Sequence< OUString > DataSeries::getSupportedServiceNames_Static() ...@@ -273,7 +245,7 @@ Sequence< OUString > DataSeries::getSupportedServiceNames_Static()
uno::Any DataSeries::GetDefaultValue( sal_Int32 nHandle ) const uno::Any DataSeries::GetDefaultValue( sal_Int32 nHandle ) const
throw(beans::UnknownPropertyException) throw(beans::UnknownPropertyException)
{ {
const tPropertyValueMap& rStaticDefaults = *StaticDataSeriesDefaults::get(); const tPropertyValueMap& rStaticDefaults = StaticDataSeriesDefaults::get();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() ) if( aFound == rStaticDefaults.end() )
return uno::Any(); return uno::Any();
...@@ -283,14 +255,14 @@ uno::Any DataSeries::GetDefaultValue( sal_Int32 nHandle ) const ...@@ -283,14 +255,14 @@ uno::Any DataSeries::GetDefaultValue( sal_Int32 nHandle ) const
// ____ OPropertySet ____ // ____ OPropertySet ____
::cppu::IPropertyArrayHelper & SAL_CALL DataSeries::getInfoHelper() ::cppu::IPropertyArrayHelper & SAL_CALL DataSeries::getInfoHelper()
{ {
return *StaticDataSeriesInfoHelper::get(); return StaticDataSeriesInfoHelper::get();
} }
// ____ XPropertySet ____ // ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL DataSeries::getPropertySetInfo() uno::Reference< beans::XPropertySetInfo > SAL_CALL DataSeries::getPropertySetInfo()
throw (uno::RuntimeException, std::exception) throw (uno::RuntimeException, std::exception)
{ {
return *StaticDataSeriesInfo::get(); return StaticDataSeriesInfo::get();
} }
void SAL_CALL DataSeries::getFastPropertyValue void SAL_CALL DataSeries::getFastPropertyValue
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment