summaryrefslogtreecommitdiff
path: root/stoc
diff options
context:
space:
mode:
authorDaniel Boelzle <dbo@openoffice.org>2002-11-13 10:00:23 +0000
committerDaniel Boelzle <dbo@openoffice.org>2002-11-13 10:00:23 +0000
commit7a852297410c6e1df498bac096d9a0f98550651d (patch)
treebbb38d0c6afd0f4034e5e3d79c01f5d9816cc3cc /stoc
parente3eefe577453c1c90d6e229aac8d7260b4645881 (diff)
#104143# throwing lang::DisposedException after dispose()
Diffstat (limited to 'stoc')
-rw-r--r--stoc/source/cppumaker.mk13
-rw-r--r--stoc/source/servicemanager/servicemanager.cxx62
-rw-r--r--stoc/test/makefile.mk6
-rw-r--r--stoc/test/testsmgr2.cxx19
4 files changed, 82 insertions, 18 deletions
diff --git a/stoc/source/cppumaker.mk b/stoc/source/cppumaker.mk
index 068c609a64ea..0819d7ebdc12 100644
--- a/stoc/source/cppumaker.mk
+++ b/stoc/source/cppumaker.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: cppumaker.mk,v $
#
-# $Revision: 1.5 $
+# $Revision: 1.6 $
#
-# last change: $Author: pluby $ $Date: 2001-02-12 20:19:41 $
+# last change: $Author: dbo $ $Date: 2002-11-13 11:00:21 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -74,3 +74,12 @@ CPPUMAKERFLAGS = -L
UNOUCROUT= $(OUT)$/inc$/light
INCPRE+= $(OUT)$/inc$/light
.ENDIF
+
+.IF "$(debug)" != ""
+
+# MSVC++: no inlining
+.IF "$(COM)" == "MSC"
+CFLAGS += -Ob0
+.ENDIF
+
+.ENDIF
diff --git a/stoc/source/servicemanager/servicemanager.cxx b/stoc/source/servicemanager/servicemanager.cxx
index c16cbfc1d0d2..3bd1a54751e4 100644
--- a/stoc/source/servicemanager/servicemanager.cxx
+++ b/stoc/source/servicemanager/servicemanager.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: servicemanager.cxx,v $
*
- * $Revision: 1.17 $
+ * $Revision: 1.18 $
*
- * last change: $Author: dbo $ $Date: 2002-11-07 15:46:09 $
+ * last change: $Author: dbo $ $Date: 2002-11-13 11:00:22 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -682,6 +682,7 @@ public:
throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
protected:
+ inline void check_undisposed() const SAL_THROW( (lang::DisposedException) );
sal_Bool haveFactoryWithThisImplementation(const OUString& aImplName);
@@ -710,6 +711,16 @@ private:
HashMap_OWString_Interface m_ImplementationNameMap;
Reference<XEventListener > xFactoryListener;
};
+//__________________________________________________________________________________________________
+inline void OServiceManager::check_undisposed() const SAL_THROW( (lang::DisposedException) )
+{
+ if (rBHelper.bDisposed || rBHelper.bInDispose)
+ {
+ throw lang::DisposedException(
+ OUSTR("service manager instance has already been disposed!"),
+ (OWeakObject *)this );
+ }
+}
//##################################################################################################
//##################################################################################################
@@ -723,8 +734,8 @@ class OServiceManagerWrapper : public OServiceManagerMutex, public t_OServiceMan
{
if (! m_root)
{
- throw DisposedException(
- OUString( RTL_CONSTASCII_USTRINGPARAM("call on already disposed smgr!") ),
+ throw lang::DisposedException(
+ OUSTR("service manager instance has already been disposed!"),
Reference< XInterface >() );
}
return m_root;
@@ -934,6 +945,7 @@ static Reference<XInterface > SAL_CALL OServiceManagerWrapper_CreateInstance(
sal_Int64 OServiceManager::getSomething( Sequence< sal_Int8 > const & id )
throw (RuntimeException)
{
+ check_undisposed();
if (id == smgr_getImplementationId())
return (sal_Int64)this;
else
@@ -1062,10 +1074,9 @@ void OServiceManager::onUnloadingNotify()
void OServiceManager::dispose()
throw(::com::sun::star::uno::RuntimeException)
{
- // notify the disposing listener, the service manager is still full alive
- EventObject aEvt;
- aEvt.Source = Reference<XInterface >( *this );
- rBHelper.aLC.disposeAndClear( aEvt );
+ if (rBHelper.bDisposed || rBHelper.bInDispose)
+ return;
+ t_OServiceManager_impl::dispose();
// dispose all factories
HashSet_Ref aImpls;
@@ -1091,9 +1102,6 @@ void OServiceManager::dispose()
}
}
- // set the service manager to disposed
- t_OServiceManager_impl::dispose();
-
// dispose
HashSet_Ref aImplMap;
{
@@ -1120,6 +1128,7 @@ void OServiceManager::dispose()
Reference<XPropertySetInfo > OServiceManager::getPropertySetInfo()
throw(::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
if (! m_xPropertyInfo.is())
{
Sequence< beans::Property > seq( 1 );
@@ -1140,6 +1149,7 @@ void OServiceManager::setPropertyValue(
const OUString& PropertyName, const Any& aValue )
throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("DefaultContext") ))
{
Reference< XComponentContext > xContext;
@@ -1166,6 +1176,7 @@ void OServiceManager::setPropertyValue(
Any OServiceManager::getPropertyValue(const OUString& PropertyName)
throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("DefaultContext") ))
{
MutexGuard aGuard( m_mutex );
@@ -1188,6 +1199,7 @@ void OServiceManager::addPropertyChangeListener(
const Reference<XPropertyChangeListener >& aListener)
throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
throw UnknownPropertyException();
}
@@ -1196,6 +1208,7 @@ void OServiceManager::removePropertyChangeListener(
const Reference<XPropertyChangeListener >& aListener)
throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
throw UnknownPropertyException();
}
@@ -1204,6 +1217,7 @@ void OServiceManager::addVetoableChangeListener(
const Reference<XVetoableChangeListener >& aListener)
throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
throw UnknownPropertyException();
}
@@ -1212,12 +1226,14 @@ void OServiceManager::removeVetoableChangeListener(
const Reference<XVetoableChangeListener >& aListener)
throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
throw UnknownPropertyException();
}
// OServiceManager
Reference<XEventListener > OServiceManager::getFactoryListener()
{
+ check_undisposed();
MutexGuard aGuard( m_mutex );
if( !xFactoryListener.is() )
xFactoryListener = new OServiceManager_Listener( this );
@@ -1227,8 +1243,8 @@ Reference<XEventListener > OServiceManager::getFactoryListener()
// XMultiServiceFactory, XContentEnumeration
Sequence< OUString > OServiceManager::getAvailableServiceNames( HashSet_OWString & aNameSet )
{
+ check_undisposed();
MutexGuard aGuard( m_mutex );
-
HashMultimap_OWString_Interface::iterator aSIt = m_ServiceMap.begin();
while( aSIt != m_ServiceMap.end() )
aNameSet.insert( (*aSIt++).first );
@@ -1256,6 +1272,7 @@ Reference< XInterface > OServiceManager::createInstanceWithContext(
Reference< XComponentContext > const & xContext )
throw (Exception, RuntimeException)
{
+ check_undisposed();
#ifdef _DEBUG
Reference< beans::XPropertySet > xProps( xContext->getServiceManager(), UNO_QUERY );
OSL_ASSERT( xProps.is() );
@@ -1316,6 +1333,7 @@ Reference< XInterface > OServiceManager::createInstanceWithArgumentsAndContext(
Reference< XComponentContext > const & xContext )
throw (Exception, RuntimeException)
{
+ check_undisposed();
#ifdef _DEBUG
Reference< beans::XPropertySet > xProps( xContext->getServiceManager(), UNO_QUERY );
OSL_ASSERT( xProps.is() );
@@ -1374,6 +1392,7 @@ Reference< XInterface > OServiceManager::createInstanceWithArgumentsAndContext(
Sequence< OUString > OServiceManager::getAvailableServiceNames()
throw(::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
// all names
HashSet_OWString aNameSet;
return getAvailableServiceNames( aNameSet );
@@ -1402,6 +1421,7 @@ Reference<XInterface > OServiceManager::createInstanceWithArguments(
void OServiceManager::initialize( Sequence< Any > const & )
throw (Exception)
{
+ check_undisposed();
OSL_ENSURE( 0, "not impl!" );
}
@@ -1409,6 +1429,7 @@ void OServiceManager::initialize( Sequence< Any > const & )
OUString OServiceManager::getImplementationName()
throw(::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
return getImplementationName_Static();
}
@@ -1416,6 +1437,7 @@ OUString OServiceManager::getImplementationName()
sal_Bool OServiceManager::supportsService(const OUString& ServiceName)
throw(::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
Sequence< OUString > aSNL = getSupportedServiceNames();
const OUString * pArray = aSNL.getConstArray();
for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
@@ -1428,6 +1450,7 @@ sal_Bool OServiceManager::supportsService(const OUString& ServiceName)
Sequence< OUString > OServiceManager::getSupportedServiceNames()
throw(::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
return smgr_getSupportedServiceNames();
}
@@ -1473,6 +1496,7 @@ Sequence< Reference< XInterface > > OServiceManager::queryServiceFactories(
Reference<XEnumeration > OServiceManager::createContentEnumeration(const OUString& aServiceName)
throw(::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
Sequence< Reference< XInterface > > factories(
OServiceManager::queryServiceFactories( aServiceName ) );
if (factories.getLength())
@@ -1484,6 +1508,7 @@ Reference<XEnumeration > OServiceManager::createContentEnumeration(const OUStrin
// XEnumeration
Reference<XEnumeration > OServiceManager::createEnumeration() throw(::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
MutexGuard aGuard( m_mutex );
return new ImplementationEnumeration_Impl( m_ImplementationMap );
}
@@ -1492,6 +1517,7 @@ Reference<XEnumeration > OServiceManager::createEnumeration() throw(::com::sun::
Type OServiceManager::getElementType()
throw(::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
return ::getCppuType( (const Reference< XInterface > *)0 );
}
@@ -1499,6 +1525,7 @@ Type OServiceManager::getElementType()
sal_Bool OServiceManager::hasElements()
throw(::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
MutexGuard aGuard( m_mutex );
return !m_ImplementationMap.empty();
}
@@ -1507,6 +1534,7 @@ sal_Bool OServiceManager::hasElements()
sal_Bool OServiceManager::has( const Any & Element )
throw(::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
if( Element.getValueTypeClass() == TypeClass_INTERFACE )
{
MutexGuard aGuard( m_mutex );
@@ -1521,6 +1549,7 @@ sal_Bool OServiceManager::has( const Any & Element )
void OServiceManager::insert( const Any & Element )
throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
if( Element.getValueTypeClass() != TypeClass_INTERFACE )
{
throw IllegalArgumentException(
@@ -1582,6 +1611,7 @@ void OServiceManager::remove( const Any & Element )
::com::sun::star::container::NoSuchElementException,
::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
if( Element.getValueTypeClass() != TypeClass_INTERFACE )
{
throw IllegalArgumentException(
@@ -1718,6 +1748,8 @@ ORegistryServiceManager::~ORegistryServiceManager()
void ORegistryServiceManager::dispose()
throw(::com::sun::star::uno::RuntimeException)
{
+ if (rBHelper.bDisposed || rBHelper.bInDispose)
+ return;
OServiceManager::dispose();
// dispose
MutexGuard aGuard( m_mutex );
@@ -1850,6 +1882,7 @@ void ORegistryServiceManager::fillAllNamesFromRegistry( HashSet_OWString & rSet
void ORegistryServiceManager::initialize(const Sequence< Any >& Arguments)
throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
MutexGuard aGuard( m_mutex );
if (Arguments.getLength() > 0)
{
@@ -1867,6 +1900,7 @@ void ORegistryServiceManager::initialize(const Sequence< Any >& Arguments)
Sequence< OUString > ORegistryServiceManager::getAvailableServiceNames()
throw(::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
MutexGuard aGuard( m_mutex );
// all names
HashSet_OWString aNameSet;
@@ -1881,6 +1915,7 @@ Sequence< OUString > ORegistryServiceManager::getAvailableServiceNames()
Sequence< OUString > ORegistryServiceManager::getSupportedServiceNames()
throw(::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
return regsmgr_getSupportedServiceNames();
}
@@ -1909,6 +1944,7 @@ Sequence< Reference< XInterface > > ORegistryServiceManager::queryServiceFactori
Reference<XEnumeration > ORegistryServiceManager::createContentEnumeration(const OUString& aServiceName)
throw(::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
MutexGuard aGuard( ((ORegistryServiceManager *)this)->m_mutex );
// get all implementation names registered under this service name from the registry
Sequence<OUString> aImpls = ((ORegistryServiceManager *)this)->getFromServiceName( aServiceName );
@@ -1931,6 +1967,7 @@ Reference<XEnumeration > ORegistryServiceManager::createContentEnumeration(const
Reference<XPropertySetInfo > ORegistryServiceManager::getPropertySetInfo()
throw(::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
if (! m_xPropertyInfo.is())
{
Sequence< beans::Property > seq( 2 );
@@ -1953,6 +1990,7 @@ Reference<XPropertySetInfo > ORegistryServiceManager::getPropertySetInfo()
Any ORegistryServiceManager::getPropertyValue(const OUString& PropertyName)
throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
{
+ check_undisposed();
if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Registry") ))
{
MutexGuard aGuard( m_mutex );
diff --git a/stoc/test/makefile.mk b/stoc/test/makefile.mk
index b87ac20a778c..8dab660c32de 100644
--- a/stoc/test/makefile.mk
+++ b/stoc/test/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.18 $
+# $Revision: 1.19 $
#
-# last change: $Author: dbo $ $Date: 2002-08-22 14:42:22 $
+# last change: $Author: dbo $ $Date: 2002-11-13 11:00:23 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -245,7 +245,7 @@ MY_DLLPREFIX=
MY_DLLPOSTFIX=.so
MY_DLLPREFIX=lib
.ENDIF
-TESTCOREFL:=ModuleC;ModuleC.XInterfaceA;ModuleC.XInterfaceB;ModuleA.XInterface1;com.sun.star.reflection.XIdlReflection;com.sun.star.reflection.XIdlField;com.sun.star.reflection.XIdlArray;com.sun.star.reflection.XIdlMethod;com.sun.star.reflection.XIdlClass;com.sun.star.beans.XPropertySet;com.sun.star.lang.XComponent;com.sun.star.container.XHierarchicalNameAccess;com.sun.star.reflection.XIdlField2
+TESTCOREFL:=ModuleC;ModuleC.XInterfaceA;ModuleC.XInterfaceB;ModuleA.XInterface1;com.sun.star.reflection.XIdlReflection;com.sun.star.reflection.XIdlField;com.sun.star.reflection.XIdlArray;com.sun.star.reflection.XIdlMethod;com.sun.star.reflection.XIdlClass;com.sun.star.beans.XPropertySet;com.sun.star.lang.XComponent;com.sun.star.container.XHierarchicalNameAccess;com.sun.star.reflection.XIdlField2;com.sun.star.lang.DisposedException
TESTIADAPTER:=com.sun.star.beans.XIntrospection;com.sun.star.beans.MethodConcept;com.sun.star.beans.XExactName;com.sun.star.lang.XTypeProvider;com.sun.star.uno.XAggregation;com.sun.star.script.XInvocationAdapterFactory;com.sun.star.script.XInvocationAdapterFactory2;com.sun.star.script.XInvocation;com.sun.star.lang.XMultiServiceFactory;com.sun.star.registry.XSimpleRegistry;com.sun.star.lang.XInitialization;test.XLanguageBindingTest
TESTINTROSP:=ModuleA;ModuleA.XIntroTest;com.sun.star.beans.XPropertySet;com.sun.star.container.XIndexAccess;com.sun.star.container.XNameAccess;com.sun.star.beans.PropertyAttribute;com.sun.star.beans.PropertyConcept
TESTCONV:=com.sun.star.script.XTypeConverter
diff --git a/stoc/test/testsmgr2.cxx b/stoc/test/testsmgr2.cxx
index 5e0fd66be951..7d8bdcbafc89 100644
--- a/stoc/test/testsmgr2.cxx
+++ b/stoc/test/testsmgr2.cxx
@@ -6,6 +6,8 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/registry/XSimpleRegistry.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
using namespace ::rtl;
using namespace ::cppu;
@@ -58,12 +60,27 @@ int main()
{
printf( "test passed\n" );
}
+
+ Reference< XComponent > xComp( rComp, UNO_QUERY );
+ xComp->dispose();
+ try
+ {
+ xCtAccess->createContentEnumeration(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "blabla" ) ) );
+ }
+ catch (DisposedException &)
+ {
+ printf( "already disposed results in DisposedException: ok.\n" );
+ return 0;
+ }
+ fprintf( stderr, "missing DisposedException!\n" );
+ return 1;
}
catch ( Exception & e )
{
OString o = OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US );
printf( "%s\n" , o.getStr() );
OSL_ASSERT( 0 );
+ return 1;
}
- return 0;
}