From 7078f667a3e39601c6d135e311de67fbab289a2b Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 5 Feb 2015 12:40:29 +0100 Subject: Don't hold refcounted objects by naked pointer (and no need to hold css::uno::Sequence objects by pointer either). Regression from e537d227d3a801076aff98c113650942fb6b3699 "hard to find accidental leaks with all the deliberate ones" caused JunitTest_svx_unoapi to sometimes crash. Change-Id: I3579c4bbac58d7e341c8acb52dd3f0f06f7b2245 --- sd/inc/sdmod.hxx | 7 ++++--- sd/source/ui/unoidl/unoobj.cxx | 26 ++++++++++++-------------- 2 files changed, 16 insertions(+), 17 deletions(-) (limited to 'sd') diff --git a/sd/inc/sdmod.hxx b/sd/inc/sdmod.hxx index d2a64acb4118..d3ae1b2882e1 100644 --- a/sd/inc/sdmod.hxx +++ b/sd/inc/sdmod.hxx @@ -23,6 +23,7 @@ #include "glob.hxx" #include "pres.hxx" +#include #include #include #include "sddllapi.h" @@ -32,7 +33,7 @@ #include #include #include -#include +#include #include class SdOptions; @@ -60,8 +61,8 @@ enum SdOptionStreamMode SD_OPTION_STORE = 1 }; -typedef boost::ptr_map< sal_uIntPtr, SfxExtItemPropertySetInfo > SdExtPropertySetInfoCache; -typedef boost::ptr_map< sal_uInt32, css::uno::Sequence< css::uno::Type> > SdTypesCache; +typedef std::map< sal_uIntPtr, rtl::Reference > SdExtPropertySetInfoCache; +typedef std::map< sal_uInt32, css::uno::Sequence< css::uno::Type> > SdTypesCache; /* diff --git a/sd/source/ui/unoidl/unoobj.cxx b/sd/source/ui/unoidl/unoobj.cxx index 47fe407a4e53..59aeaa2d29e9 100644 --- a/sd/source/ui/unoidl/unoobj.cxx +++ b/sd/source/ui/unoidl/unoobj.cxx @@ -19,7 +19,7 @@ #include -#include +#include #include #include @@ -338,24 +338,24 @@ uno::Sequence< uno::Type > SAL_CALL SdXShape::getTypes() else { sal_uInt32 nObjId = mpShape->getShapeKind(); - uno::Sequence< uno::Type >* pTypes; + uno::Sequence< uno::Type > aTypes; SdTypesCache& gImplTypesCache = SD_MOD()->gImplTypesCache; SdTypesCache::iterator aIter( gImplTypesCache.find( nObjId ) ); if( aIter == gImplTypesCache.end() ) { - pTypes = new uno::Sequence< uno::Type >( mpShape->_getTypes() ); - sal_uInt32 nCount = pTypes->getLength(); - pTypes->realloc( nCount+1 ); - (*pTypes)[nCount] = cppu::UnoType::get(); + aTypes = mpShape->_getTypes(); + sal_uInt32 nCount = aTypes.getLength(); + aTypes.realloc( nCount+1 ); + aTypes[nCount] = cppu::UnoType::get(); - gImplTypesCache.insert(nObjId, pTypes); + gImplTypesCache.insert(std::make_pair(nObjId, aTypes)); } else { // use the already computed implementation id - pTypes = (*aIter).second; + aTypes = (*aIter).second; } - return *pTypes; + return aTypes; } } @@ -422,7 +422,7 @@ uno::Any SAL_CALL SdXShape::getPropertyDefault( const OUString& aPropertyName ) throw(::com::sun::star::uno::RuntimeException) { sal_uIntPtr nObjId = reinterpret_cast(mpShape->getPropertyMapEntries()); - SfxExtItemPropertySetInfo* pInfo = NULL; + rtl::Reference pInfo; SdExtPropertySetInfoCache& rCache = (mpModel && mpModel->IsImpressDocument()) ? SD_MOD()->gImplImpressPropertySetInfoCache : SD_MOD()->gImplDrawPropertySetInfoCache; @@ -432,9 +432,8 @@ uno::Any SAL_CALL SdXShape::getPropertyDefault( const OUString& aPropertyName ) { uno::Reference< beans::XPropertySetInfo > xInfo( mpShape->_getPropertySetInfo() ); pInfo = new SfxExtItemPropertySetInfo( mpMap, xInfo->getProperties() ); - pInfo->acquire(); - rCache.insert(nObjId, pInfo); + rCache.insert(std::make_pair(nObjId, pInfo)); } else { @@ -442,8 +441,7 @@ uno::Any SAL_CALL SdXShape::getPropertyDefault( const OUString& aPropertyName ) pInfo = (*aIter).second; } - uno::Reference< beans::XPropertySetInfo > xInfo( pInfo ); - return pInfo; + return pInfo.get(); } void SAL_CALL SdXShape::setPropertyValue( const OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) -- cgit