diff options
-rw-r--r-- | sot/source/sdstor/ucbstorage.cxx | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/sot/source/sdstor/ucbstorage.cxx b/sot/source/sdstor/ucbstorage.cxx index 0e428dab4b25..b0801e3a0060 100644 --- a/sot/source/sdstor/ucbstorage.cxx +++ b/sot/source/sdstor/ucbstorage.cxx @@ -43,6 +43,7 @@ #include <com/sun/star/packages/manifest/ManifestReader.hpp> #include <com/sun/star/ucb/InteractiveIOException.hpp> +#include <boost/scoped_ptr.hpp> #include <rtl/digest.h> #include <tools/ref.hxx> #include <tools/debug.hxx> @@ -2139,15 +2140,15 @@ sal_Int16 UCBStorage_Impl::Commit() { UCBStorageElement_Impl* pElement = m_aChildrenList[ i ]; ::ucbhelper::Content* pContent = pElement->GetContent(); - bool bDeleteContent = false; + boost::scoped_ptr< ::ucbhelper::Content > xDeleteContent; if ( !pContent && pElement->IsModified() ) { // if the element has never been opened, no content has been created until now - bDeleteContent = true; // remember to delete it later OUString aName( m_aURL ); aName += "/"; aName += pElement->m_aOriginalName; pContent = new ::ucbhelper::Content( aName, Reference< ::com::sun::star::ucb::XCommandEnvironment >(), comphelper::getProcessComponentContext() ); + xDeleteContent.reset(pContent); // delete it later on exit scope } if ( pElement->m_bIsRemoved ) @@ -2220,10 +2221,6 @@ sal_Int16 UCBStorage_Impl::Commit() nRet = nLocalRet; } - if ( bDeleteContent ) - // content was created inside the loop - delete pContent; - if ( nRet == COMMIT_RESULT_FAILURE ) break; } |