summaryrefslogtreecommitdiff
path: root/cppuhelper
diff options
context:
space:
mode:
authorDaniel Boelzle <dbo@openoffice.org>2001-06-07 10:55:14 +0000
committerDaniel Boelzle <dbo@openoffice.org>2001-06-07 10:55:14 +0000
commite12b6ba3d593f0d3b93f68d9bb63aab1db993158 (patch)
tree2c44020a607ba552723231934ed5888967b52aa6 /cppuhelper
parentcebdbf89512850b0eb8c608b8ef840450d956842 (diff)
#87233# fixed disposing sequence: context entries, smgr, tdmgr
Diffstat (limited to 'cppuhelper')
-rw-r--r--cppuhelper/source/component_context.cxx83
1 files changed, 53 insertions, 30 deletions
diff --git a/cppuhelper/source/component_context.cxx b/cppuhelper/source/component_context.cxx
index f11c37bbc467..84b56a3d8778 100644
--- a/cppuhelper/source/component_context.cxx
+++ b/cppuhelper/source/component_context.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: component_context.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: dbo $ $Date: 2001-06-01 11:47:46 $
+ * last change: $Author: dbo $ $Date: 2001-06-07 11:55:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -86,12 +86,15 @@
#include <hash_map>
+#define SMGR_NAME "com.sun.star.lang.ServiceManager"
+#define TDMGR_NAME "com.sun.star.reflection.TypeDescriptionManager"
+
+
using namespace ::osl;
using namespace ::rtl;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star;
-
namespace cppu
{
@@ -212,22 +215,22 @@ Any ComponentContext::getValueByName( OUString const & rName )
if (xInstance.is())
{
ClearableMutexGuard aGuard( m_mutex );
- if (! pEntry->bLateInitService) // inited in the meantime?
+ if (pEntry->bLateInitService)
+ {
+ pEntry->value.setValue( &xInstance, ::getCppuType( &xInstance ) );
+ pEntry->bLateInitService = false;
+ }
+ else // inited in the meantime
{
aGuard.clear();
// service has entered the context in the meantime
- // => try to dispose this one
+ // => try to dispose this object
Reference< lang::XComponent > xComp( xInstance, UNO_QUERY );
if (xComp.is())
{
xComp->dispose();
}
}
- else
- {
- pEntry->value.setValue( &xInstance, ::getCppuType( &xInstance ) );
- pEntry->bLateInitService = false;
- }
return pEntry->value;
}
@@ -253,8 +256,7 @@ Any ComponentContext::getValueByName( OUString const & rName )
return Any(); // error occured
}
-
- if (m_xDelegate.is())
+ else if (m_xDelegate.is())
{
return m_xDelegate->getValueByName( rName );
}
@@ -281,31 +283,46 @@ void ComponentContext::disposing()
::fprintf( stderr, "> disposing context %p\n", this );
#endif
- // dispose all context objects
+ Reference< lang::XComponent > xTDMgr; // to be disposed separately
+
+ // first dispose all context objects
t_map::const_iterator iPos( m_map.begin() );
for ( ; iPos != m_map.end(); ++iPos )
{
ContextEntry * pEntry = iPos->second;
- Reference< lang::XComponent > xComp;
- if (pEntry->bLateInitService)
- {
- // may be in late init
- MutexGuard aGuard( m_mutex );
- pEntry->value >>= xComp;
- }
- else
+ // service manager disposed separately
+ if (!m_xSMgr.is() || !iPos->first.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(SMGR_NAME) ))
{
- pEntry->value >>= xComp;
- }
+ Reference< lang::XComponent > xComp;
- if (xComp.is())
- {
- xComp->dispose();
+ if (pEntry->bLateInitService)
+ {
+ // may be in late init
+ MutexGuard aGuard( m_mutex );
+ pEntry->value >>= xComp;
+ }
+ else
+ {
+ pEntry->value >>= xComp;
+ }
+
+ if (xComp.is())
+ {
+ if (iPos->first.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(TDMGR_NAME) ))
+ {
+ // disposed separately
+ xTDMgr = xComp;
+ }
+ else
+ {
+ xComp->dispose();
+ }
+ }
}
}
- // dispose service manager
+ // second dispose service manager
if (m_bDisposeSMgr)
{
Reference< lang::XComponent > xComp( m_xSMgr, UNO_QUERY );
@@ -315,11 +332,18 @@ void ComponentContext::disposing()
}
}
+ // last dispose of tdmgr: revoke callback from cppu runtime
+ if (xTDMgr.is())
+ {
+ xTDMgr->dispose();
+ }
+
// everything is disposed, hopefully nobody accesses the context anymore...
for ( iPos = m_map.begin(); iPos != m_map.end(); ++iPos )
{
delete iPos->second;
}
+
m_map.clear();
}
//__________________________________________________________________________________________________
@@ -334,10 +358,9 @@ ComponentContext::ComponentContext(
{
ContextEntry_Init const & rEntry = pEntries[ nEntries ];
- if (rEntry.name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.lang.ServiceManager") ))
+ if (rEntry.name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(SMGR_NAME) ))
{
- if (rEntry.value >>= m_xSMgr)
- continue;
+ rEntry.value >>= m_xSMgr;
}
m_map[ rEntry.name ] = new ContextEntry( rEntry.bLateInitService, rEntry.value );
}