Kaydet (Commit) 415c2e54 authored tarafından Noel Grandin's avatar Noel Grandin

use unique_ptr in connectivity

Change-Id: I333a3bc21d4afade6d29f096390b5edbd4e78bf9
Reviewed-on: https://gerrit.libreoffice.org/65403
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst ef8de8d2
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <dbase/DResultSet.hxx> #include <dbase/DResultSet.hxx>
#include <strings.hrc> #include <strings.hrc>
#include <unotools/sharedunocomponent.hxx> #include <unotools/sharedunocomponent.hxx>
#include <o3tl/make_unique.hxx>
using namespace ::comphelper; using namespace ::comphelper;
...@@ -159,10 +160,10 @@ void ODbaseIndex::openIndexFile() ...@@ -159,10 +160,10 @@ void ODbaseIndex::openIndexFile()
} }
} }
OIndexIterator* ODbaseIndex::createIterator() std::unique_ptr<OIndexIterator> ODbaseIndex::createIterator()
{ {
openIndexFile(); openIndexFile();
return new OIndexIterator(this); return o3tl::make_unique<OIndexIterator>(this);
} }
bool ODbaseIndex::ConvertToKey(ONDXKey* rKey, sal_uInt32 nRec, const ORowSetValue& rValue) bool ODbaseIndex::ConvertToKey(ONDXKey* rKey, sal_uInt32 nRec, const ORowSetValue& rValue)
......
...@@ -163,7 +163,7 @@ bool ODbaseResultSet::fillIndexValues(const Reference< XColumnsSupplier> &_xInde ...@@ -163,7 +163,7 @@ bool ODbaseResultSet::fillIndexValues(const Reference< XColumnsSupplier> &_xInde
dbase::ODbaseIndex* pIndex = reinterpret_cast< dbase::ODbaseIndex* >( xTunnel->getSomething(dbase::ODbaseIndex::getUnoTunnelImplementationId()) ); dbase::ODbaseIndex* pIndex = reinterpret_cast< dbase::ODbaseIndex* >( xTunnel->getSomething(dbase::ODbaseIndex::getUnoTunnelImplementationId()) );
if(pIndex) if(pIndex)
{ {
dbase::OIndexIterator* pIter = pIndex->createIterator(); std::unique_ptr<dbase::OIndexIterator> pIter = pIndex->createIterator();
if (pIter) if (pIter)
{ {
...@@ -174,7 +174,6 @@ bool ODbaseResultSet::fillIndexValues(const Reference< XColumnsSupplier> &_xInde ...@@ -174,7 +174,6 @@ bool ODbaseResultSet::fillIndexValues(const Reference< XColumnsSupplier> &_xInde
nRec = pIter->Next(); nRec = pIter->Next();
} }
m_pFileSet->setFrozen(); m_pFileSet->setFrozen();
delete pIter;
return true; return true;
} }
} }
......
...@@ -196,14 +196,13 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTables( ...@@ -196,14 +196,13 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTables(
{ {
if ( t.pEnv->IsInstanceOf( jThrow,java_sql_SQLException_BASE::st_getMyClass() ) ) if ( t.pEnv->IsInstanceOf( jThrow,java_sql_SQLException_BASE::st_getMyClass() ) )
{ {
java_sql_SQLException_BASE* pException = new java_sql_SQLException_BASE( t.pEnv, jThrow ); java_sql_SQLException_BASE aException( t.pEnv, jThrow );
SQLException e( pException->getMessage(), SQLException e( aException.getMessage(),
*this, *this,
pException->getSQLState(), aException.getSQLState(),
pException->getErrorCode(), aException.getErrorCode(),
Any() Any()
); );
delete pException;
throw e; throw e;
} }
} }
......
...@@ -770,7 +770,7 @@ bool java_sql_Connection::construct(const OUString& url, ...@@ -770,7 +770,7 @@ bool java_sql_Connection::construct(const OUString& url,
jvalue args[2]; jvalue args[2];
// convert Parameter // convert Parameter
args[0].l = convertwchar_tToJavaString(t.pEnv,url); args[0].l = convertwchar_tToJavaString(t.pEnv,url);
java_util_Properties* pProps = createStringPropertyArray(info); std::unique_ptr<java_util_Properties> pProps = createStringPropertyArray(info);
args[1].l = pProps->getJavaObject(); args[1].l = pProps->getJavaObject();
LocalRef< jobject > ensureDelete( t.env(), args[0].l ); LocalRef< jobject > ensureDelete( t.env(), args[0].l );
...@@ -792,8 +792,7 @@ bool java_sql_Connection::construct(const OUString& url, ...@@ -792,8 +792,7 @@ bool java_sql_Connection::construct(const OUString& url,
{ {
ContextClassLoaderScope ccl( t.env(), getDriverClassLoader(), getLogger(), *this ); ContextClassLoaderScope ccl( t.env(), getDriverClassLoader(), getLogger(), *this );
out = t.pEnv->CallObjectMethod( m_pDriverobject, mID, args[0].l,args[1].l ); out = t.pEnv->CallObjectMethod( m_pDriverobject, mID, args[0].l,args[1].l );
delete pProps; pProps.reset();
pProps = nullptr;
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
} }
......
...@@ -103,9 +103,9 @@ jstring connectivity::convertwchar_tToJavaString(JNIEnv *pEnv,const OUString& _r ...@@ -103,9 +103,9 @@ jstring connectivity::convertwchar_tToJavaString(JNIEnv *pEnv,const OUString& _r
} }
java_util_Properties* connectivity::createStringPropertyArray(const Sequence< PropertyValue >& info ) std::unique_ptr<java_util_Properties> connectivity::createStringPropertyArray(const Sequence< PropertyValue >& info )
{ {
java_util_Properties* pProps = new java_util_Properties(); std::unique_ptr<java_util_Properties> pProps(new java_util_Properties());
const PropertyValue* pBegin = info.getConstArray(); const PropertyValue* pBegin = info.getConstArray();
const PropertyValue* pEnd = pBegin + info.getLength(); const PropertyValue* pEnd = pBegin + info.getLength();
......
...@@ -101,7 +101,7 @@ namespace connectivity ...@@ -101,7 +101,7 @@ namespace connectivity
const ODbaseTable* getTable() const { return m_pTable; } const ODbaseTable* getTable() const { return m_pTable; }
const NDXHeader& getHeader() const { return m_aHeader; } const NDXHeader& getHeader() const { return m_aHeader; }
OIndexIterator* createIterator(); std::unique_ptr<OIndexIterator> createIterator();
void SetRootPos(sal_uInt32 nPos) {m_nRootPage = nPos;} void SetRootPos(sal_uInt32 nPos) {m_nRootPage = nPos;}
void SetPageCount(sal_uInt32 nCount) {m_nPageCount = nCount;} void SetPageCount(sal_uInt32 nCount) {m_nPageCount = nCount;}
......
...@@ -42,7 +42,7 @@ namespace connectivity ...@@ -42,7 +42,7 @@ namespace connectivity
/// @throws css::sdbc::SQLException /// @throws css::sdbc::SQLException
/// @throws css::uno::RuntimeException /// @throws css::uno::RuntimeException
java_util_Properties* createStringPropertyArray(const css::uno::Sequence< css::beans::PropertyValue >& info ); std::unique_ptr<java_util_Properties> createStringPropertyArray(const css::uno::Sequence< css::beans::PropertyValue >& info );
jobject convertTypeMapToJavaMap(const css::uno::Reference< css::container::XNameAccess > & _rMap); jobject convertTypeMapToJavaMap(const css::uno::Reference< css::container::XNameAccess > & _rMap);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment