Tag: cws_src680_dba24a User: oj Date: 2007-09-05 11:03:00+0000 Modified: dba/dbaccess/source/core/api/TableDeco.cxx dba/dbaccess/source/core/api/tablecontainer.cxx dba/dbaccess/source/core/inc/ContainerMediator.hxx dba/dbaccess/source/core/misc/ContainerMediator.cxx dba/dbaccess/source/core/misc/PropertyForward.cxx
Log: #i68334# fix ref count prob File Changes: Directory: /dba/dbaccess/source/core/api/ ========================================= File [changed]: TableDeco.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/api/TableDeco.cxx?r1=1.31&r2=1.31.36.1 Delta lines: +24 -26 --------------------- --- TableDeco.cxx 2007-05-10 10:11:43+0000 1.31 +++ TableDeco.cxx 2007-09-05 11:02:57+0000 1.31.36.1 @@ -4,9 +4,9 @@ * * $RCSfile: TableDeco.cxx,v $ * - * $Revision: 1.31 $ + * $Revision: 1.31.36.1 $ * - * last change: $Author: kz $ $Date: 2007/05/10 10:11:43 $ + * last change: $Author: oj $ $Date: 2007/09/05 11:02:57 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -174,11 +174,9 @@ m_pTables = NULL; m_xColumnDefinitions = NULL; m_xNumberFormats = NULL; - m_xColumnMediator = NULL; if ( m_pColumns ) - { m_pColumns->disposing(); - } + m_xColumnMediator = NULL; } // ----------------------------------------------------------------------------- sal_Bool SAL_CALL ODBTableDecorator::convertFastPropertyValue( @@ -398,22 +396,22 @@ Reference<XPropertySetInfo> xInfo = xProp->getPropertySetInfo(); Sequence< Property > aTableProps = xInfo->getProperties(); - Property* pBegin = aTableProps.getArray(); - Property* pEnd = pBegin + aTableProps.getLength(); - for (;pBegin != pEnd ; ++pBegin) - { - if (0 == pBegin->Name.compareToAscii(PROPERTY_CATALOGNAME)) - pBegin->Handle = PROPERTY_ID_CATALOGNAME; - else if (0 ==pBegin->Name.compareToAscii(PROPERTY_SCHEMANAME)) - pBegin->Handle = PROPERTY_ID_SCHEMANAME; - else if (0 ==pBegin->Name.compareToAscii(PROPERTY_NAME)) - pBegin->Handle = PROPERTY_ID_NAME; - else if (0 ==pBegin->Name.compareToAscii(PROPERTY_DESCRIPTION)) - pBegin->Handle = PROPERTY_ID_DESCRIPTION; - else if (0 ==pBegin->Name.compareToAscii(PROPERTY_TYPE)) - pBegin->Handle = PROPERTY_ID_TYPE; - else if (0 ==pBegin->Name.compareToAscii(PROPERTY_PRIVILEGES)) - pBegin->Handle = PROPERTY_ID_PRIVILEGES; + Property* pIter = aTableProps.getArray(); + Property* pEnd = pIter + aTableProps.getLength(); + for (;pIter != pEnd ; ++pIter) + { + if (0 == pIter->Name.compareToAscii(PROPERTY_CATALOGNAME)) + pIter->Handle = PROPERTY_ID_CATALOGNAME; + else if (0 ==pIter->Name.compareToAscii(PROPERTY_SCHEMANAME)) + pIter->Handle = PROPERTY_ID_SCHEMANAME; + else if (0 ==pIter->Name.compareToAscii(PROPERTY_NAME)) + pIter->Handle = PROPERTY_ID_NAME; + else if (0 ==pIter->Name.compareToAscii(PROPERTY_DESCRIPTION)) + pIter->Handle = PROPERTY_ID_DESCRIPTION; + else if (0 ==pIter->Name.compareToAscii(PROPERTY_TYPE)) + pIter->Handle = PROPERTY_ID_TYPE; + else if (0 ==pIter->Name.compareToAscii(PROPERTY_PRIVILEGES)) + pIter->Handle = PROPERTY_ID_PRIVILEGES; } describeProperties(aTableProps); @@ -647,10 +645,10 @@ if(xNames.is()) { Sequence< ::rtl::OUString> aNames = xNames->getElementNames(); - const ::rtl::OUString* pBegin = aNames.getConstArray(); - const ::rtl::OUString* pEnd = pBegin + aNames.getLength(); - for(;pBegin != pEnd;++pBegin) - aVector.push_back(*pBegin); + const ::rtl::OUString* pIter = aNames.getConstArray(); + const ::rtl::OUString* pEnd = pIter + aNames.getLength(); + for(;pIter != pEnd;++pIter) + aVector.push_back(*pIter); } } if(!m_pColumns) File [changed]: tablecontainer.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/api/tablecontainer.cxx?r1=1.64&r2=1.64.108.1 Delta lines: +6 -5 ------------------- --- tablecontainer.cxx 2006-10-18 13:27:52+0000 1.64 +++ tablecontainer.cxx 2007-09-05 11:02:57+0000 1.64.108.1 @@ -4,9 +4,9 @@ * * $RCSfile: tablecontainer.cxx,v $ * - * $Revision: 1.64 $ + * $Revision: 1.64.108.1 $ * - * last change: $Author: ihi $ $Date: 2006/10/18 13:27:52 $ + * last change: $Author: oj $ $Date: 2007/09/05 11:02:57 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -197,8 +197,6 @@ ,m_bInDrop(sal_False) { DBG_CTOR(OTableContainer, NULL); - m_pTableMediator = new OContainerMediator( - this, Reference< XNameAccess >( _xTableDefinitions, UNO_QUERY ), m_xConnection, OContainerMediator::eTables ); } //------------------------------------------------------------------------------ @@ -344,6 +342,9 @@ if ( xTableDefinition.is() ) ::comphelper::copyProperties(xTableDefinition,xDest); + if ( !m_pTableMediator.is() ) + m_pTableMediator = new OContainerMediator( + this, m_xTableDefinitions.get(), m_xConnection, OContainerMediator::eTables ); if ( m_pTableMediator.is() ) m_pTableMediator->notifyElementCreated(_rName,xDest); } Directory: /dba/dbaccess/source/core/inc/ ========================================= File [changed]: ContainerMediator.hxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/inc/ContainerMediator.hxx?r1=1.5&r2=1.5.108.1 Delta lines: +5 -5 ------------------- --- ContainerMediator.hxx 2006-10-18 13:28:07+0000 1.5 +++ ContainerMediator.hxx 2007-09-05 11:02:57+0000 1.5.108.1 @@ -4,9 +4,9 @@ * * $RCSfile: ContainerMediator.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.5.108.1 $ * - * last change: $Author: ihi $ $Date: 2006/10/18 13:28:07 $ + * last change: $Author: oj $ $Date: 2007/09/05 11:02:57 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -87,8 +87,8 @@ typedef ::rtl::Reference< OPropertyForward > TPropertyForward; typedef ::std::map< ::rtl::OUString, TPropertyForward > PropertyForwardList; PropertyForwardList m_aForwardList; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xSettings; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer > m_xContainer; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xSettings; // can not be weak + ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer > m_xContainer; // can not be weak ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XConnection > m_aConnection; ContainerType m_eType; Directory: /dba/dbaccess/source/core/misc/ ========================================== File [changed]: ContainerMediator.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/misc/ContainerMediator.cxx?r1=1.8&r2=1.8.108.1 Delta lines: +41 -26 --------------------- --- ContainerMediator.cxx 2006-10-18 13:29:28+0000 1.8 +++ ContainerMediator.cxx 2007-09-05 11:02:57+0000 1.8.108.1 @@ -4,9 +4,9 @@ * * $RCSfile: ContainerMediator.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.8.108.1 $ * - * last change: $Author: ihi $ $Date: 2006/10/18 13:29:28 $ + * last change: $Author: oj $ $Date: 2007/09/05 11:02:57 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -89,11 +89,14 @@ , m_eType( _eType ) { DBG_CTOR(OContainerMediator,NULL); + + if ( _xSettings.is() && _xContainer.is() ) + { osl_incrementInterlockedCount(&m_refCount); try { m_xContainer->addContainerListener(this); - Reference< XContainer > xContainer(m_xSettings, UNO_QUERY); + Reference< XContainer > xContainer(_xSettings, UNO_QUERY); if ( xContainer.is() ) xContainer->addContainerListener(this); } @@ -102,6 +105,12 @@ OSL_ENSURE(sal_False, "OContainerMediator::OContainerMediator: caught an exception!"); } osl_decrementInterlockedCount( &m_refCount ); + } + else + { + m_xSettings.clear(); + m_xContainer.clear(); + } } // ----------------------------------------------------------------------------- OContainerMediator::~OContainerMediator() @@ -119,11 +128,14 @@ Reference< XContainer > xContainer( m_xSettings, UNO_QUERY ); if ( xContainer.is() ) xContainer->removeContainerListener( this ); - m_xSettings = NULL; + m_xSettings.clear(); + + xContainer = m_xContainer; + if ( xContainer.is() ) + xContainer->removeContainerListener( this ); + m_xContainer.clear();//WeakReference< XContainer >(); - if ( m_xContainer.is() ) - m_xContainer->removeContainerListener( this ); - m_xContainer = NULL; + m_aForwardList.clear(); } catch( const Exception& ) { @@ -151,7 +163,8 @@ void SAL_CALL OContainerMediator::elementRemoved( const ContainerEvent& _rEvent ) throw(RuntimeException) { ::osl::MutexGuard aGuard(m_aMutex); - if ( _rEvent.Source == m_xContainer && m_xContainer.is() ) + Reference< XContainer > xContainer = m_xContainer; + if ( _rEvent.Source == xContainer && xContainer.is() ) { ::rtl::OUString sElementName; _rEvent.Accessor >>= sElementName; @@ -176,11 +189,13 @@ } // ----------------------------------------------------------------------------- -void SAL_CALL OContainerMediator::disposing( const EventObject& Source ) throw(RuntimeException) +void SAL_CALL OContainerMediator::disposing( const EventObject& /*Source*/ ) throw(RuntimeException) { ::osl::MutexGuard aGuard(m_aMutex); - if ( Source.Source == m_xContainer || Source.Source == m_xSettings ) +// Reference< XContainer > xContainer = m_xContainer; +// if ( Source.Source == xContainer || Source.Source == m_xSettings ) + // this can only be one of them :-) So no check needed here impl_cleanup_nothrow(); } @@ -191,7 +206,7 @@ Reference< XPropertySet > xSettings; try { - if ( m_xSettings->hasByName( _rName ) ) + if ( m_xSettings.is() && m_xSettings->hasByName( _rName ) ) OSL_VERIFY( m_xSettings->getByName( _rName ) >>= xSettings ); else if ( m_eType == eColumns ) { File [changed]: PropertyForward.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/misc/PropertyForward.cxx?r1=1.9&r2=1.9.18.1 Delta lines: +4 -3 ------------------- --- PropertyForward.cxx 2007-07-06 07:55:19+0000 1.9 +++ PropertyForward.cxx 2007-09-05 11:02:58+0000 1.9.18.1 @@ -4,9 +4,9 @@ * * $RCSfile: PropertyForward.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.9.18.1 $ * - * last change: $Author: rt $ $Date: 2007/07/06 07:55:19 $ + * last change: $Author: oj $ $Date: 2007/09/05 11:02:58 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -79,6 +79,7 @@ { DBG_CTOR(OPropertyForward,NULL); OSL_ENSURE(_xDestContainer.is(),"OPropertyForward::OPropertyForward: destination should be valid!"); + OSL_ENSURE(m_xSource.is(),"OPropertyForward::OPropertyForward: source must be valid!"); osl_incrementInterlockedCount(&m_refCount); try { --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
