From 3dfe5e64eea1771ecc8be4ccd9e3ada609810059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Barfurth?= Date: Sun, 3 Dec 2000 10:58:37 +0000 Subject: [PATCH] #81172# Corrected lifetime handling during provider-originated notification dispatch --- configmgr/source/api2/apitreeimplobj.cxx | 33 +++++++++++++++++++----- configmgr/source/api2/apitreeimplobj.hxx | 5 ++-- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/configmgr/source/api2/apitreeimplobj.cxx b/configmgr/source/api2/apitreeimplobj.cxx index d232dd4db666..e28449948365 100644 --- a/configmgr/source/api2/apitreeimplobj.cxx +++ b/configmgr/source/api2/apitreeimplobj.cxx @@ -2,9 +2,9 @@ * * $RCSfile: apitreeimplobj.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: dg $ $Date: 2000-11-30 20:32:19 $ + * last change: $Author: jb $ $Date: 2000-12-03 11:58:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -164,9 +164,14 @@ void ApiTreeImpl::setNodeInstance(configuration::NodeRef const& aNode, UnoInterf //------------------------------------------------------------------------- +bool ApiTreeImpl::isAlive() const +{ + return m_aNotifier->m_aListeners.checkAlive(); +} +//------------------------------------------------------------------------- void ApiTreeImpl::checkAlive() const { - bool bAlive = m_aNotifier->m_aListeners.checkAlive(); + bool bAlive = this->isAlive(); if (!bAlive) { OUString sMessage(RTL_CONSTASCII_USTRINGPARAM("CONFIGURATION: Object was disposed")); @@ -391,6 +396,9 @@ uno::Any SAL_CALL ApiTreeImpl::queryInterface(uno::Type const& rType) throw() void SAL_CALL ApiTreeImpl::disposing(com::sun::star::lang::EventObject const& rEvt) throw() { + // this is a non-UNO external entry point - we need to keep this object alive for the duration of the call + UnoInterfaceRef xKeepAlive( getUnoInstance() ); + // Tree write Lock should be set by sender setParentTree(0); implDisposeTree(); @@ -447,7 +455,11 @@ void ApiRootTreeImpl::implSetLocation() void ApiRootTreeImpl::disposing(IConfigBroadcaster* pSource) { - OSL_ASSERT(pSource == m_pNotificationSource); + // this is a non-UNO external entry point - we need to keep this object alive for the duration of the call + UnoInterfaceRef xKeepAlive( m_aTreeImpl.getUnoInstance() ); + + OSL_VERIFY( implSetNotificationSource(0) == pSource || !m_aTreeImpl.isAlive()); + m_pNotificationSource = 0; m_aTreeImpl.disposeTree(true); @@ -509,12 +521,17 @@ void ApiRootTreeImpl::nodeChanged(Change const& aChange, OUString const& sPath, using configuration::NodeChanges; using configuration::RelativePath; - OSL_ASSERT( m_pNotificationSource == pSource ); + // this is a non-UNO external entry point - we need to keep this object alive for the duration of the call + UnoInterfaceRef xKeepAlive( m_aTreeImpl.getUnoInstance() ); + // do not dipatch if we are dying/dead anyway + if (m_aTreeImpl.isAlive()) try { OClearableWriteSynchronized aLocalGuard(m_aTreeImpl.getDataLock()); + OSL_ASSERT( m_pNotificationSource == pSource ); + Tree aTree( m_aTreeImpl.getTree() ); OSL_ENSURE( Path(sPath, Path::NoValidate()).getType() == configuration::PathType::eABSOLUTE, @@ -576,9 +593,13 @@ void ApiRootTreeImpl::nodeChanged(Change const& aChange, OUString const& sPath, void ApiRootTreeImpl::nodeDeleted(OUString const& sPath, IConfigBroadcaster* pSource) { + // this is a non-UNO external entry point - we need to keep this object alive for the duration of the call + UnoInterfaceRef xKeepAlive( m_aTreeImpl.getUnoInstance() ); + #ifdef DBG_UTIL using configuration::Path; + { OReadSynchronized aLocalGuard(m_aTreeImpl.getDataLock()); @@ -594,7 +615,7 @@ void ApiRootTreeImpl::nodeDeleted(OUString const& sPath, IConfigBroadcaster* pSo } #endif - OSL_VERIFY( implSetNotificationSource(0) == pSource ); + OSL_VERIFY( implSetNotificationSource(0) == pSource || !m_aTreeImpl.isAlive()); m_aTreeImpl.disposeTree(true); } diff --git a/configmgr/source/api2/apitreeimplobj.hxx b/configmgr/source/api2/apitreeimplobj.hxx index af88953f90af..b6963bf032a2 100644 --- a/configmgr/source/api2/apitreeimplobj.hxx +++ b/configmgr/source/api2/apitreeimplobj.hxx @@ -2,9 +2,9 @@ * * $RCSfile: apitreeimplobj.hxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: dg $ $Date: 2000-11-30 08:38:33 $ + * last change: $Author: jb $ $Date: 2000-12-03 11:58:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -154,6 +154,7 @@ namespace configmgr Tree getTree() const { return m_aTree; } // self-locked methods for dispose handling + bool isAlive() const; void checkAlive() const; bool disposeTree(bool bForce); void disposeNode(configuration::NodeRef const& aNode, UnoInterface* pInstance);