coverity#983214 Resource leak
... and some more general cleanup by using boost stuff. Change-Id: I90b2f429f864c39cda70d42d061da14c0faba8e5
This commit is contained in:
@@ -32,6 +32,8 @@
|
|||||||
**************************************************************************
|
**************************************************************************
|
||||||
|
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
#include <boost/ptr_container/ptr_vector.hpp>
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <osl/diagnose.h>
|
#include <osl/diagnose.h>
|
||||||
#include <com/sun/star/ucb/OpenMode.hpp>
|
#include <com/sun/star/ucb/OpenMode.hpp>
|
||||||
#include <ucbhelper/contentidentifier.hxx>
|
#include <ucbhelper/contentidentifier.hxx>
|
||||||
@@ -60,10 +62,11 @@ struct ResultListEntry
|
|||||||
uno::Reference< ucb::XContentIdentifier > xId;
|
uno::Reference< ucb::XContentIdentifier > xId;
|
||||||
uno::Reference< ucb::XContent > xContent;
|
uno::Reference< ucb::XContent > xContent;
|
||||||
uno::Reference< sdbc::XRow > xRow;
|
uno::Reference< sdbc::XRow > xRow;
|
||||||
const ContentProperties* pData;
|
boost::shared_ptr<ContentProperties> const pData;
|
||||||
|
|
||||||
ResultListEntry( const ContentProperties* pEntry ) : pData( pEntry ) {};
|
ResultListEntry(boost::shared_ptr<ContentProperties> const& pEntry)
|
||||||
~ResultListEntry() { delete pData; }
|
: pData(pEntry)
|
||||||
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
@@ -72,7 +75,7 @@ struct ResultListEntry
|
|||||||
//
|
//
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
|
|
||||||
typedef std::vector< ResultListEntry* > ResultList;
|
typedef boost::ptr_vector<ResultListEntry> ResultList;
|
||||||
|
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
//
|
//
|
||||||
@@ -96,22 +99,8 @@ struct DataSupplier_Impl
|
|||||||
sal_Int32 nOpenMode )
|
sal_Int32 nOpenMode )
|
||||||
: m_xContent( rContent ), m_xContext( rxContext ), m_nOpenMode( nOpenMode ),
|
: m_xContent( rContent ), m_xContext( rxContext ), m_nOpenMode( nOpenMode ),
|
||||||
m_bCountFinal( sal_False ), m_bThrowException( sal_False ) {}
|
m_bCountFinal( sal_False ), m_bThrowException( sal_False ) {}
|
||||||
~DataSupplier_Impl();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//=========================================================================
|
|
||||||
DataSupplier_Impl::~DataSupplier_Impl()
|
|
||||||
{
|
|
||||||
ResultList::const_iterator it = m_aResults.begin();
|
|
||||||
ResultList::const_iterator end = m_aResults.end();
|
|
||||||
|
|
||||||
while ( it != end )
|
|
||||||
{
|
|
||||||
delete (*it);
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
@@ -134,7 +123,6 @@ DataSupplier::DataSupplier(
|
|||||||
// virtual
|
// virtual
|
||||||
DataSupplier::~DataSupplier()
|
DataSupplier::~DataSupplier()
|
||||||
{
|
{
|
||||||
delete m_pImpl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
@@ -145,7 +133,7 @@ rtl::OUString DataSupplier::queryContentIdentifierString( sal_uInt32 nIndex )
|
|||||||
|
|
||||||
if ( nIndex < m_pImpl->m_aResults.size() )
|
if ( nIndex < m_pImpl->m_aResults.size() )
|
||||||
{
|
{
|
||||||
rtl::OUString aId = m_pImpl->m_aResults[ nIndex ]->aId;
|
rtl::OUString aId = m_pImpl->m_aResults[ nIndex ].aId;
|
||||||
if ( !aId.isEmpty() )
|
if ( !aId.isEmpty() )
|
||||||
{
|
{
|
||||||
// Already cached.
|
// Already cached.
|
||||||
@@ -158,7 +146,7 @@ rtl::OUString DataSupplier::queryContentIdentifierString( sal_uInt32 nIndex )
|
|||||||
rtl::OUString aId = m_pImpl->m_xContent->getResourceAccess().getURL();
|
rtl::OUString aId = m_pImpl->m_xContent->getResourceAccess().getURL();
|
||||||
|
|
||||||
const ContentProperties& props
|
const ContentProperties& props
|
||||||
= *( m_pImpl->m_aResults[ nIndex ]->pData );
|
= *( m_pImpl->m_aResults[ nIndex ].pData );
|
||||||
|
|
||||||
if ( ( aId.lastIndexOf( '/' ) + 1 ) != aId.getLength() )
|
if ( ( aId.lastIndexOf( '/' ) + 1 ) != aId.getLength() )
|
||||||
aId += rtl::OUString("/");
|
aId += rtl::OUString("/");
|
||||||
@@ -168,7 +156,7 @@ rtl::OUString DataSupplier::queryContentIdentifierString( sal_uInt32 nIndex )
|
|||||||
if ( props.isTrailingSlash() )
|
if ( props.isTrailingSlash() )
|
||||||
aId += rtl::OUString("/");
|
aId += rtl::OUString("/");
|
||||||
|
|
||||||
m_pImpl->m_aResults[ nIndex ]->aId = aId;
|
m_pImpl->m_aResults[ nIndex ].aId = aId;
|
||||||
return aId;
|
return aId;
|
||||||
}
|
}
|
||||||
return rtl::OUString();
|
return rtl::OUString();
|
||||||
@@ -184,7 +172,7 @@ DataSupplier::queryContentIdentifier( sal_uInt32 nIndex )
|
|||||||
if ( nIndex < m_pImpl->m_aResults.size() )
|
if ( nIndex < m_pImpl->m_aResults.size() )
|
||||||
{
|
{
|
||||||
uno::Reference< ucb::XContentIdentifier > xId
|
uno::Reference< ucb::XContentIdentifier > xId
|
||||||
= m_pImpl->m_aResults[ nIndex ]->xId;
|
= m_pImpl->m_aResults[ nIndex ].xId;
|
||||||
if ( xId.is() )
|
if ( xId.is() )
|
||||||
{
|
{
|
||||||
// Already cached.
|
// Already cached.
|
||||||
@@ -197,7 +185,7 @@ DataSupplier::queryContentIdentifier( sal_uInt32 nIndex )
|
|||||||
{
|
{
|
||||||
uno::Reference< ucb::XContentIdentifier > xId
|
uno::Reference< ucb::XContentIdentifier > xId
|
||||||
= new ::ucbhelper::ContentIdentifier( aId );
|
= new ::ucbhelper::ContentIdentifier( aId );
|
||||||
m_pImpl->m_aResults[ nIndex ]->xId = xId;
|
m_pImpl->m_aResults[ nIndex ].xId = xId;
|
||||||
return xId;
|
return xId;
|
||||||
}
|
}
|
||||||
return uno::Reference< ucb::XContentIdentifier >();
|
return uno::Reference< ucb::XContentIdentifier >();
|
||||||
@@ -213,7 +201,7 @@ DataSupplier::queryContent( sal_uInt32 nIndex )
|
|||||||
if ( nIndex < m_pImpl->m_aResults.size() )
|
if ( nIndex < m_pImpl->m_aResults.size() )
|
||||||
{
|
{
|
||||||
uno::Reference< ucb::XContent > xContent
|
uno::Reference< ucb::XContent > xContent
|
||||||
= m_pImpl->m_aResults[ nIndex ]->xContent;
|
= m_pImpl->m_aResults[ nIndex ].xContent;
|
||||||
if ( xContent.is() )
|
if ( xContent.is() )
|
||||||
{
|
{
|
||||||
// Already cached.
|
// Already cached.
|
||||||
@@ -229,7 +217,7 @@ DataSupplier::queryContent( sal_uInt32 nIndex )
|
|||||||
{
|
{
|
||||||
uno::Reference< ucb::XContent > xContent
|
uno::Reference< ucb::XContent > xContent
|
||||||
= m_pImpl->m_xContent->getProvider()->queryContent( xId );
|
= m_pImpl->m_xContent->getProvider()->queryContent( xId );
|
||||||
m_pImpl->m_aResults[ nIndex ]->xContent = xContent;
|
m_pImpl->m_aResults[ nIndex ].xContent = xContent;
|
||||||
return xContent;
|
return xContent;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -298,7 +286,7 @@ uno::Reference< sdbc::XRow > DataSupplier::queryPropertyValues(
|
|||||||
|
|
||||||
if ( nIndex < m_pImpl->m_aResults.size() )
|
if ( nIndex < m_pImpl->m_aResults.size() )
|
||||||
{
|
{
|
||||||
uno::Reference< sdbc::XRow > xRow = m_pImpl->m_aResults[ nIndex ]->xRow;
|
uno::Reference< sdbc::XRow > xRow = m_pImpl->m_aResults[ nIndex ].xRow;
|
||||||
if ( xRow.is() )
|
if ( xRow.is() )
|
||||||
{
|
{
|
||||||
// Already cached.
|
// Already cached.
|
||||||
@@ -312,11 +300,11 @@ uno::Reference< sdbc::XRow > DataSupplier::queryPropertyValues(
|
|||||||
= Content::getPropertyValues(
|
= Content::getPropertyValues(
|
||||||
m_pImpl->m_xContext,
|
m_pImpl->m_xContext,
|
||||||
getResultSet()->getProperties(),
|
getResultSet()->getProperties(),
|
||||||
*(m_pImpl->m_aResults[ nIndex ]->pData),
|
*(m_pImpl->m_aResults[ nIndex ].pData),
|
||||||
rtl::Reference< ::ucbhelper::ContentProviderImplHelper >(
|
rtl::Reference< ::ucbhelper::ContentProviderImplHelper >(
|
||||||
m_pImpl->m_xContent->getProvider().get() ),
|
m_pImpl->m_xContent->getProvider().get() ),
|
||||||
queryContentIdentifierString( nIndex ) );
|
queryContentIdentifierString( nIndex ) );
|
||||||
m_pImpl->m_aResults[ nIndex ]->xRow = xRow;
|
m_pImpl->m_aResults[ nIndex ].xRow = xRow;
|
||||||
return xRow;
|
return xRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,7 +318,7 @@ void DataSupplier::releasePropertyValues( sal_uInt32 nIndex )
|
|||||||
osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
|
osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
|
||||||
|
|
||||||
if ( nIndex < m_pImpl->m_aResults.size() )
|
if ( nIndex < m_pImpl->m_aResults.size() )
|
||||||
m_pImpl->m_aResults[ nIndex ]->xRow = uno::Reference< sdbc::XRow >();
|
m_pImpl->m_aResults[ nIndex ].xRow = uno::Reference< sdbc::XRow >();
|
||||||
}
|
}
|
||||||
|
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
@@ -444,8 +432,8 @@ sal_Bool DataSupplier::getData()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentProperties* pContentProperties
|
boost::shared_ptr<ContentProperties> const
|
||||||
= new ContentProperties( rRes );
|
pContentProperties(new ContentProperties(rRes));
|
||||||
|
|
||||||
// Check resource against open mode.
|
// Check resource against open mode.
|
||||||
switch ( m_pImpl->m_nOpenMode )
|
switch ( m_pImpl->m_nOpenMode )
|
||||||
|
@@ -26,10 +26,11 @@
|
|||||||
*
|
*
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
#ifndef _WEBDAV_UCP_DATASUPPLIER_HXX
|
#ifndef WEBDAV_UCP_DATASUPPLIER_HXX
|
||||||
#define _WEBDAV_UCP_DATASUPPLIER_HXX
|
#define WEBDAV_UCP_DATASUPPLIER_HXX
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <boost/scoped_ptr.hpp>
|
||||||
#include <rtl/ref.hxx>
|
#include <rtl/ref.hxx>
|
||||||
#include <ucbhelper/resultset.hxx>
|
#include <ucbhelper/resultset.hxx>
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ class Content;
|
|||||||
|
|
||||||
class DataSupplier : public ucbhelper::ResultSetDataSupplier
|
class DataSupplier : public ucbhelper::ResultSetDataSupplier
|
||||||
{
|
{
|
||||||
DataSupplier_Impl* m_pImpl;
|
boost::scoped_ptr<DataSupplier_Impl> m_pImpl;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sal_Bool getData();
|
sal_Bool getData();
|
||||||
|
Reference in New Issue
Block a user