diff options
author | Lionel Elie Mamane <lionel@mamane.lu> | 2014-06-18 22:46:33 +0200 |
---|---|---|
committer | Lionel Elie Mamane <lionel@mamane.lu> | 2014-06-18 22:46:53 +0200 |
commit | 4c6a27aaad6ef35d5f25312a9bc411afa77871f5 (patch) | |
tree | 063865b661d1d7607b63817b12be9768e172d5a6 /connectivity/source | |
parent | b800ba097f083062c61772b38754584ed5e8167c (diff) |
Use rtl::Reference to make code clearer & exception-safe
Change-Id: I8cfdf792541b351a19e16f95d4e6f7127e3d33b2
Diffstat (limited to 'connectivity/source')
-rw-r--r-- | connectivity/source/drivers/file/FPreparedStatement.cxx | 34 | ||||
-rw-r--r-- | connectivity/source/inc/file/FPreparedStatement.hxx | 2 |
2 files changed, 14 insertions, 22 deletions
diff --git a/connectivity/source/drivers/file/FPreparedStatement.cxx b/connectivity/source/drivers/file/FPreparedStatement.cxx index 2d7db2fa5ff1..5e166db428f7 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 e380c84d2ddd..07d1302bda31 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); |