diff options
author | Caolán McNamara <caolanm@redhat.com> | 2010-11-25 20:36:03 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2010-11-25 20:36:03 +0000 |
commit | 83ab35b7351ba42097efc9c2b04044038e50e4f7 (patch) | |
tree | 16d9cc994bb549167c182201897f142f53e25890 /configmgr/source/access.cxx | |
parent | c5ca3f408ff0cd4796e74ad871171c5ba84fe406 (diff) |
Resolves: fdo#31494# get ownership right
Ensure that the mutex lives as long as all its consumers. And
avoid launching threads if they have no work to do.
Diffstat (limited to 'configmgr/source/access.cxx')
-rw-r--r-- | configmgr/source/access.cxx | 96 |
1 files changed, 49 insertions, 47 deletions
diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx index fda967a28463..0382054533da 100644 --- a/configmgr/source/access.cxx +++ b/configmgr/source/access.cxx @@ -166,7 +166,9 @@ void Access::initBroadcaster( Access::Access(Components & components): components_(components), disposed_(false) -{} +{ + lock_ = lock(); +} Access::~Access() {} @@ -851,7 +853,7 @@ css::uno::Sequence< css::uno::Type > Access::getTypes() throw (css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_ANY)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); comphelper::SequenceAsVector< css::uno::Type > types; types.push_back(cppu::UnoType< css::uno::XInterface >::get()); @@ -900,7 +902,7 @@ css::uno::Sequence< sal_Int8 > Access::getImplementationId() throw (css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_ANY)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); return css::uno::Sequence< sal_Int8 >(); } @@ -908,7 +910,7 @@ css::uno::Sequence< sal_Int8 > Access::getImplementationId() rtl::OUString Access::getImplementationName() throw (css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_ANY)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); throw css::uno::RuntimeException( rtl::OUString( @@ -921,7 +923,7 @@ sal_Bool Access::supportsService(rtl::OUString const & ServiceName) throw (css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_ANY)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); css::uno::Sequence< rtl::OUString > names(getSupportedServiceNames()); for (sal_Int32 i = 0; i < names.getLength(); ++i) { @@ -936,7 +938,7 @@ css::uno::Sequence< rtl::OUString > Access::getSupportedServiceNames() throw (css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_ANY)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); comphelper::SequenceAsVector< rtl::OUString > services; services.push_back( @@ -1000,7 +1002,7 @@ void Access::dispose() throw (css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_ANY)); Broadcaster bc; { - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); if (getParentAccess().is()) { throw css::uno::RuntimeException( @@ -1025,7 +1027,7 @@ void Access::addEventListener( { OSL_ASSERT(thisIs(IS_ANY)); { - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); if (!xListener.is()) { throw css::uno::RuntimeException( @@ -1048,7 +1050,7 @@ void Access::removeEventListener( throw (css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_ANY)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); DisposeListeners::iterator i(disposeListeners_.find(aListener)); if (i != disposeListeners_.end()) { @@ -1058,7 +1060,7 @@ void Access::removeEventListener( css::uno::Type Access::getElementType() throw (css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_ANY)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); rtl::Reference< Node > p(getNode()); switch (p->kind()) { @@ -1082,7 +1084,7 @@ css::uno::Type Access::getElementType() throw (css::uno::RuntimeException) { sal_Bool Access::hasElements() throw (css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_ANY)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); return !getAllChildren().empty(); //TODO: optimize } @@ -1093,7 +1095,7 @@ css::uno::Any Access::getByName(rtl::OUString const & aName) css::lang::WrappedTargetException, css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_ANY)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); rtl::Reference< ChildAccess > child(getChild(aName)); if (!child.is()) { @@ -1107,7 +1109,7 @@ css::uno::Sequence< rtl::OUString > Access::getElementNames() throw (css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_ANY)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); std::vector< rtl::Reference< ChildAccess > > children(getAllChildren()); comphelper::SequenceAsVector< rtl::OUString > names; @@ -1124,7 +1126,7 @@ sal_Bool Access::hasByName(rtl::OUString const & aName) throw (css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_ANY)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); return getChild(aName).is(); } @@ -1133,7 +1135,7 @@ css::uno::Any Access::getByHierarchicalName(rtl::OUString const & aName) throw (css::container::NoSuchElementException, css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_ANY)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); rtl::Reference< ChildAccess > child(getSubChild(aName)); if (!child.is()) { @@ -1147,7 +1149,7 @@ sal_Bool Access::hasByHierarchicalName(rtl::OUString const & aName) throw (css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_ANY)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); return getSubChild(aName).is(); } @@ -1158,7 +1160,7 @@ void Access::addContainerListener( { OSL_ASSERT(thisIs(IS_ANY)); { - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); if (!xListener.is()) { throw css::uno::RuntimeException( @@ -1181,7 +1183,7 @@ void Access::removeContainerListener( throw (css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_ANY)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); ContainerListeners::iterator i(containerListeners_.find(xListener)); if (i != containerListeners_.end()) { @@ -1193,7 +1195,7 @@ rtl::OUString Access::getExactName(rtl::OUString const & aApproximateName) throw (css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_ANY)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); return aApproximateName; } @@ -1202,7 +1204,7 @@ css::uno::Sequence< css::beans::Property > Access::getProperties() throw (css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_GROUP)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); std::vector< rtl::Reference< ChildAccess > > children(getAllChildren()); comphelper::SequenceAsVector< css::beans::Property > properties; for (std::vector< rtl::Reference< ChildAccess > >::iterator i( @@ -1218,7 +1220,7 @@ css::beans::Property Access::getPropertyByName(rtl::OUString const & aName) throw (css::beans::UnknownPropertyException, css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_GROUP)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); rtl::Reference< ChildAccess > child(getChild(aName)); if (!child.is()) { throw css::beans::UnknownPropertyException( @@ -1231,13 +1233,13 @@ sal_Bool Access::hasPropertyByName(rtl::OUString const & Name) throw (css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_GROUP)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); return getChild(Name).is(); } rtl::OUString Access::getHierarchicalName() throw (css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_ANY)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); // For backwards compatibility, return an absolute path representation where // available: @@ -1261,7 +1263,7 @@ rtl::OUString Access::composeHierarchicalName( css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_ANY)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); if (aRelativeName.getLength() == 0 || aRelativeName[0] == '/') { throw css::lang::IllegalArgumentException( @@ -1281,7 +1283,7 @@ rtl::OUString Access::composeHierarchicalName( rtl::OUString Access::getName() throw (css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_ANY)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); return getNameInternal(); } @@ -1292,7 +1294,7 @@ void Access::setName(rtl::OUString const & aName) OSL_ASSERT(thisIs(IS_ANY)); Broadcaster bc; { - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); checkFinalized(); Modifications localMods; @@ -1356,7 +1358,7 @@ void Access::setName(rtl::OUString const & aName) css::beans::Property Access::getAsProperty() throw (css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_ANY)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); return asProperty(); } @@ -1378,7 +1380,7 @@ void Access::setPropertyValue( OSL_ASSERT(thisIs(IS_GROUP)); Broadcaster bc; { - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); if (!getRootAccess()->isUpdate()) { throw css::uno::RuntimeException( rtl::OUString( @@ -1402,7 +1404,7 @@ css::uno::Any Access::getPropertyValue(rtl::OUString const & PropertyName) css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_GROUP)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); rtl::Reference< ChildAccess > child(getChild(PropertyName)); if (!child.is()) { throw css::beans::UnknownPropertyException( @@ -1421,7 +1423,7 @@ void Access::addPropertyChangeListener( { OSL_ASSERT(thisIs(IS_GROUP)); { - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); if (!xListener.is()) { throw css::uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("null listener")), @@ -1448,7 +1450,7 @@ void Access::removePropertyChangeListener( css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_GROUP)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkKnownProperty(aPropertyName); PropertyChangeListeners::iterator i( propertyChangeListeners_.find(aPropertyName)); @@ -1473,7 +1475,7 @@ void Access::addVetoableChangeListener( { OSL_ASSERT(thisIs(IS_GROUP)); { - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); if (!aListener.is()) { throw css::uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("null listener")), @@ -1501,7 +1503,7 @@ void Access::removeVetoableChangeListener( css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_GROUP)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkKnownProperty(PropertyName); VetoableChangeListeners::iterator i( vetoableChangeListeners_.find(PropertyName)); @@ -1526,7 +1528,7 @@ void Access::setPropertyValues( OSL_ASSERT(thisIs(IS_GROUP)); Broadcaster bc; { - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); if (!getRootAccess()->isUpdate()) { throw css::uno::RuntimeException( rtl::OUString( @@ -1563,7 +1565,7 @@ css::uno::Sequence< css::uno::Any > Access::getPropertyValues( throw (css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_GROUP)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); css::uno::Sequence< css::uno::Any > vals(aPropertyNames.getLength()); for (sal_Int32 i = 0; i < aPropertyNames.getLength(); ++i) { rtl::Reference< ChildAccess > child(getChild(aPropertyNames[i])); @@ -1588,7 +1590,7 @@ void Access::addPropertiesChangeListener( { OSL_ASSERT(thisIs(IS_GROUP)); { - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); if (!xListener.is()) { throw css::uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("null listener")), @@ -1611,7 +1613,7 @@ void Access::removePropertiesChangeListener( throw (css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_GROUP)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); PropertiesChangeListeners::iterator i( propertiesChangeListeners_.find(xListener)); if (i != propertiesChangeListeners_.end()) { @@ -1654,7 +1656,7 @@ void Access::setHierarchicalPropertyValue( OSL_ASSERT(thisIs(IS_GROUP)); Broadcaster bc; { - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); if (!getRootAccess()->isUpdate()) { throw css::uno::RuntimeException( rtl::OUString( @@ -1686,7 +1688,7 @@ css::uno::Any Access::getHierarchicalPropertyValue( css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_GROUP)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); rtl::Reference< ChildAccess > child(getSubChild(aHierarchicalPropertyName)); if (!child.is()) { throw css::beans::UnknownPropertyException( @@ -1706,7 +1708,7 @@ void Access::setHierarchicalPropertyValues( OSL_ASSERT(thisIs(IS_GROUP)); Broadcaster bc; { - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); if (!getRootAccess()->isUpdate()) { throw css::uno::RuntimeException( rtl::OUString( @@ -1750,7 +1752,7 @@ css::uno::Sequence< css::uno::Any > Access::getHierarchicalPropertyValues( css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_GROUP)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); css::uno::Sequence< css::uno::Any > vals( aHierarchicalPropertyNames.getLength()); for (sal_Int32 i = 0; i < aHierarchicalPropertyNames.getLength(); ++i) { @@ -1774,7 +1776,7 @@ css::beans::Property Access::getPropertyByHierarchicalName( throw (css::beans::UnknownPropertyException, css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_GROUP)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); rtl::Reference< ChildAccess > child(getSubChild(aHierarchicalName)); if (!child.is()) { throw css::beans::UnknownPropertyException( @@ -1788,7 +1790,7 @@ sal_Bool Access::hasPropertyByHierarchicalName( throw (css::uno::RuntimeException) { OSL_ASSERT(thisIs(IS_GROUP)); - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); return getSubChild(aHierarchicalName).is(); } @@ -1802,7 +1804,7 @@ void Access::replaceByName( OSL_ASSERT(thisIs(IS_UPDATE)); Broadcaster bc; { - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); rtl::Reference< ChildAccess > child(getChild(aName)); if (!child.is()) { @@ -1846,7 +1848,7 @@ void Access::insertByName( OSL_ASSERT(thisIs(IS_EXTENSIBLE|IS_UPDATE)); Broadcaster bc; { - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); checkFinalized(); if (getChild(aName).is()) { @@ -1896,7 +1898,7 @@ void Access::removeByName(rtl::OUString const & aName) OSL_ASSERT(thisIs(IS_EXTENSIBLE|IS_UPDATE)); Broadcaster bc; { - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); checkLocalizedPropertyAccess(); rtl::Reference< ChildAccess > child(getChild(aName)); if (!child.is() || child->isFinalized() || @@ -2189,7 +2191,7 @@ rtl::Reference< Access > Access::getNotificationRoot() { #if OSL_DEBUG_LEVEL > 0 bool Access::thisIs(int what) { - osl::MutexGuard g(lock); + osl::MutexGuard g(*lock_); rtl::Reference< Node > p(getNode()); Node::Kind k(p->kind()); return k != Node::KIND_PROPERTY && k != Node::KIND_LOCALIZED_VALUE && |