[Libreoffice-commits] core.git: connectivity/source
Lionel Elie Mamane
lionel at mamane.lu
Wed Jun 18 13:48:02 PDT 2014
connectivity/source/drivers/file/FPreparedStatement.cxx | 34 ++++++----------
connectivity/source/inc/file/FPreparedStatement.hxx | 2
2 files changed, 14 insertions(+), 22 deletions(-)
New commits:
commit 4c6a27aaad6ef35d5f25312a9bc411afa77871f5
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date: Wed Jun 18 22:46:33 2014 +0200
Use rtl::Reference to make code clearer & exception-safe
Change-Id: I8cfdf792541b351a19e16f95d4e6f7127e3d33b2
diff --git a/connectivity/source/drivers/file/FPreparedStatement.cxx b/connectivity/source/drivers/file/FPreparedStatement.cxx
index 2d7db2f..5e166db 100644
--- a/connectivity/source/drivers/file/FPreparedStatement.cxx
+++ b/connectivity/source/drivers/file/FPreparedStatement.cxx
@@ -99,16 +99,15 @@ void OPreparedStatement::construct(const OUString& sql) throw(SQLException, Run
OResultSet::setBoundedColumns(m_aEvaluateRow,aTemp,m_xParamColumns,xNames,false,m_xDBMetaData,m_aColMapping);
}
-Reference<XResultSet> OPreparedStatement::makeResultSet()
+rtl::Reference<OResultSet> OPreparedStatement::makeResultSet()
{
closeResultSet();
- OResultSet *pResultSet = createResultSet();
- Reference<XResultSet> xRS(pResultSet);
- initializeResultSet(pResultSet);
- initResultSet(pResultSet);
- m_xResultSet = xRS;
- return xRS;
+ rtl::Reference<OResultSet> xResultSet(createResultSet());
+ m_xResultSet = xResultSet.get();
+ initializeResultSet(xResultSet.get());
+ initResultSet(xResultSet.get());
+ return xResultSet;
}
Any SAL_CALL OPreparedStatement::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
@@ -156,13 +155,10 @@ sal_Bool SAL_CALL OPreparedStatement::execute( ) throw(SQLException, RuntimeExc
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
- Reference<XResultSet> xRS(makeResultSet());
-
+ rtl::Reference<OResultSet> xRS(makeResultSet());
// since we don't support the XMultipleResults interface, nobody will ever get that ResultSet...
- Reference< XComponent > xComp(xRS, UNO_QUERY);
- assert(xComp.is() || !xRS.is());
- if (xComp.is())
- xComp->dispose();
+ if(xRS.is())
+ xRS->dispose();
return m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT;
}
@@ -173,16 +169,12 @@ sal_Int32 SAL_CALL OPreparedStatement::executeUpdate( ) throw(SQLException, Run
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
- Reference<XResultSet> xRS(makeResultSet());
+ rtl::Reference<OResultSet> xRS(makeResultSet());
if(xRS.is())
{
- assert(dynamic_cast<OResultSet*>(xRS.get()));
- const sal_Int32 res(static_cast<OResultSet*>(xRS.get())->getRowCountResult());
+ const sal_Int32 res(xRS->getRowCountResult());
// nobody will ever get that ResultSet...
- Reference< XComponent > xComp(xRS, UNO_QUERY);
- assert(xComp.is());
- if (xComp.is())
- xComp->dispose();
+ xRS->dispose();
return res;
}
else
@@ -210,7 +202,7 @@ Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( ) throw(SQLE
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
- return makeResultSet();
+ return makeResultSet().get();
}
diff --git a/connectivity/source/inc/file/FPreparedStatement.hxx b/connectivity/source/inc/file/FPreparedStatement.hxx
index e380c84..07d1302 100644
--- a/connectivity/source/inc/file/FPreparedStatement.hxx
+++ b/connectivity/source/inc/file/FPreparedStatement.hxx
@@ -53,7 +53,7 @@ namespace connectivity
// factory method for resultset's
virtual OResultSet* createResultSet() SAL_OVERRIDE;
- ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > makeResultSet();
+ ::rtl::Reference< OResultSet > makeResultSet();
void initResultSet(OResultSet*);
void checkAndResizeParameters(sal_Int32 parameterIndex);
More information about the Libreoffice-commits
mailing list