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

tdf#92440: Reduce code areas covered by mutex

Change-Id: Iec79e088e67e1cddeb8242d069fae911b305f613
üst b6cefd5e
...@@ -1537,6 +1537,7 @@ public: ...@@ -1537,6 +1537,7 @@ public:
private: private:
virtual void SAL_CALL disposing() SAL_OVERRIDE { virtual void SAL_CALL disposing() SAL_OVERRIDE {
osl::MutexGuard g(m_aMutex);
reflection_.clear(); reflection_.clear();
classCache_.clear(); classCache_.clear();
typeCache_.clear(); typeCache_.clear();
...@@ -1572,16 +1573,20 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect( ...@@ -1572,16 +1573,20 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect(
css::uno::Any const & aObject) css::uno::Any const & aObject)
throw (css::uno::RuntimeException, std::exception) throw (css::uno::RuntimeException, std::exception)
{ {
osl::MutexGuard g(m_aMutex); css::uno::Reference<css::reflection::XIdlReflection> reflection;
if (rBHelper.bDisposed || rBHelper.bInDispose) { {
throw css::lang::DisposedException( osl::MutexGuard g(m_aMutex);
getImplementationName(), static_cast<OWeakObject *>(this)); if (rBHelper.bDisposed || rBHelper.bInDispose) {
throw css::lang::DisposedException(
getImplementationName(), static_cast<OWeakObject *>(this));
}
reflection = reflection_;
} }
css::uno::Any aToInspectObj; css::uno::Any aToInspectObj;
css::uno::Type t; css::uno::Type t;
if (aObject >>= t) { if (aObject >>= t) {
css::uno::Reference<css::reflection::XIdlClass> c( css::uno::Reference<css::reflection::XIdlClass> c(
reflection_->forName(t.getTypeName())); reflection->forName(t.getTypeName()));
if (!c.is()) { if (!c.is()) {
SAL_WARN("stoc", "cannot reflect type " << t.getTypeName()); SAL_WARN("stoc", "cannot reflect type " << t.getTypeName());
return css::uno::Reference<css::beans::XIntrospectionAccess>(); return css::uno::Reference<css::beans::XIntrospectionAccess>();
...@@ -1632,7 +1637,7 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect( ...@@ -1632,7 +1637,7 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect(
const Type* pTypes = SupportedTypesSeq.getConstArray(); const Type* pTypes = SupportedTypesSeq.getConstArray();
for( sal_Int32 i = 0 ; i < nTypeCount ; i++ ) for( sal_Int32 i = 0 ; i < nTypeCount ; i++ )
{ {
pClasses[i] = reflection_->forName(pTypes[i].getTypeName()); pClasses[i] = reflection->forName(pTypes[i].getTypeName());
} }
// TODO: Caching! // TODO: Caching!
} }
...@@ -1641,7 +1646,7 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect( ...@@ -1641,7 +1646,7 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect(
"stoc", "stoc",
"object of type \"" << aToInspectObj.getValueTypeName() "object of type \"" << aToInspectObj.getValueTypeName()
<< "\" lacks XTypeProvider"); << "\" lacks XTypeProvider");
xImplClass = reflection_->forName(aToInspectObj.getValueTypeName()); xImplClass = reflection->forName(aToInspectObj.getValueTypeName());
SupportedClassSeq.realloc(1); SupportedClassSeq.realloc(1);
SupportedClassSeq[0] = xImplClass; SupportedClassSeq[0] = xImplClass;
} }
...@@ -1651,24 +1656,36 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect( ...@@ -1651,24 +1656,36 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect(
if( xPropSet.is() ) if( xPropSet.is() )
xPropSetInfo = xPropSet->getPropertySetInfo(); xPropSetInfo = xPropSet->getPropertySetInfo();
} else { } else {
xImplClass = reflection_->forName(aToInspectObj.getValueTypeName()); xImplClass = reflection->forName(aToInspectObj.getValueTypeName());
} }
if (xTypeProvider.is()) { if (xTypeProvider.is()) {
TypeKey key(xPropSetInfo, xTypeProvider->getTypes()); TypeKey key(xPropSetInfo, xTypeProvider->getTypes());
osl::MutexGuard g(m_aMutex);
if (rBHelper.bDisposed || rBHelper.bInDispose) {
throw css::lang::DisposedException(
getImplementationName(), static_cast<OWeakObject *>(this));
}
pAccess = typeCache_.find(key); pAccess = typeCache_.find(key);
if (pAccess.is()) { if (pAccess.is()) {
return new ImplIntrospectionAccess(aToInspectObj, pAccess); return new ImplIntrospectionAccess(aToInspectObj, pAccess);
} }
pAccess = new IntrospectionAccessStatic_Impl(reflection_); pAccess = new IntrospectionAccessStatic_Impl(reflection);
typeCache_.insert(key, pAccess); typeCache_.insert(key, pAccess);
} else if (xImplClass.is()) { } else if (xImplClass.is()) {
ClassKey key(xPropSetInfo, xImplClass, SupportedClassSeq); ClassKey key(xPropSetInfo, xImplClass, SupportedClassSeq);
osl::MutexGuard g(m_aMutex);
if (rBHelper.bDisposed || rBHelper.bInDispose) {
throw css::lang::DisposedException(
getImplementationName(), static_cast<OWeakObject *>(this));
}
pAccess = classCache_.find(key); pAccess = classCache_.find(key);
if (pAccess.is()) { if (pAccess.is()) {
return new ImplIntrospectionAccess(aToInspectObj, pAccess); return new ImplIntrospectionAccess(aToInspectObj, pAccess);
} }
pAccess = new IntrospectionAccessStatic_Impl(reflection_); pAccess = new IntrospectionAccessStatic_Impl(reflection);
classCache_.insert(key, pAccess); classCache_.insert(key, pAccess);
} }
...@@ -1681,7 +1698,7 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect( ...@@ -1681,7 +1698,7 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect(
sal_Int32 i; sal_Int32 i;
if( !pAccess.is() ) if( !pAccess.is() )
pAccess = new IntrospectionAccessStatic_Impl( reflection_ ); pAccess = new IntrospectionAccessStatic_Impl( reflection );
// Referenzen auf wichtige Daten von pAccess // Referenzen auf wichtige Daten von pAccess
sal_Int32& rPropCount = pAccess->mnPropCount; sal_Int32& rPropCount = pAccess->mnPropCount;
...@@ -2317,7 +2334,7 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect( ...@@ -2317,7 +2334,7 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect(
// void als Default-Klasse eintragen // void als Default-Klasse eintragen
css::uno::Reference<css::reflection::XIdlClass> css::uno::Reference<css::reflection::XIdlClass>
xListenerClass( xListenerClass(
reflection_->forName( reflection->forName(
cppu::UnoType<void>::get() cppu::UnoType<void>::get()
.getTypeName())); .getTypeName()));
// ALT: Reference<XIdlClass> xListenerClass = Void_getReflection()->getIdlClass(); // ALT: Reference<XIdlClass> xListenerClass = Void_getReflection()->getIdlClass();
...@@ -2329,7 +2346,7 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect( ...@@ -2329,7 +2346,7 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect(
css::uno::Reference<css::reflection::XIdlClass> css::uno::Reference<css::reflection::XIdlClass>
xEventListenerClass( xEventListenerClass(
reflection_->forName( reflection->forName(
cppu::UnoType< cppu::UnoType<
css::lang::XEventListener>::get() css::lang::XEventListener>::get()
.getTypeName())); .getTypeName()));
...@@ -2404,7 +2421,7 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect( ...@@ -2404,7 +2421,7 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect(
// Ist es ein Interface oder eine struct? // Ist es ein Interface oder eine struct?
//Reference<XIdlClass> xClassRef = aToInspectObj.getReflection()->getIdlClass(); //Reference<XIdlClass> xClassRef = aToInspectObj.getReflection()->getIdlClass();
css::uno::Reference<css::reflection::XIdlClass> xClassRef( css::uno::Reference<css::reflection::XIdlClass> xClassRef(
reflection_->forName(aToInspectObj.getValueTypeName())); reflection->forName(aToInspectObj.getValueTypeName()));
if( !xClassRef.is() ) if( !xClassRef.is() )
{ {
SAL_WARN( "stoc", "Can't get XIdlClass from Reflection" ); SAL_WARN( "stoc", "Can't get XIdlClass from Reflection" );
......
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