improve type-safety in dbaccess::OConnection

Change-Id: I39ebd277431407b65c5c4a80698714399d39330f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182531
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
This commit is contained in:
Noel Grandin
2025-03-05 12:49:12 +02:00
parent f6f1c7eb64
commit 6e031fc7d6
2 changed files with 9 additions and 5 deletions

View File

@ -111,7 +111,7 @@ Reference< XStatement > OConnection::createStatement()
MutexGuard aGuard(m_aMutex);
checkDisposed();
Reference< XStatement > xStatement;
rtl::Reference< OStatement > xStatement;
Reference< XStatement > xMasterStatement = m_xMasterConnection->createStatement();
if ( xMasterStatement.is() )
{
@ -127,7 +127,7 @@ Reference< XPreparedStatement > OConnection::prepareStatement(const OUString& s
checkDisposed();
// TODO convert the SQL to SQL the driver understands
Reference< XPreparedStatement > xStatement;
rtl::Reference< OPreparedStatement > xStatement;
Reference< XPreparedStatement > xMasterStatement = m_xMasterConnection->prepareStatement(sql);
if ( xMasterStatement.is() )
{
@ -142,7 +142,7 @@ Reference< XPreparedStatement > OConnection::prepareCall(const OUString& sql)
MutexGuard aGuard(m_aMutex);
checkDisposed();
Reference< XPreparedStatement > xStatement;
rtl::Reference< OCallableStatement > xStatement;
Reference< XPreparedStatement > xMasterStatement = m_xMasterConnection->prepareCall(sql);
if ( xMasterStatement.is() )
{
@ -428,7 +428,7 @@ void OConnection::disposing()
for (auto const& statement : m_aStatements)
{
Reference<XComponent> xComp(statement.get(),UNO_QUERY);
rtl::Reference<OStatementBase> xComp(statement.get());
::comphelper::disposeComponent(xComp);
}
m_aStatements.clear();

View File

@ -49,6 +49,8 @@
#include <connectivity/warningscontainer.hxx>
#include <unotools/weakref.hxx>
class OStatementBase;
namespace dbaccess
{
@ -76,7 +78,9 @@ class OConnection final :public OConnection_Base
unotools::WeakReference<ODatabaseSource> m_xParent;
css::uno::Reference< css::sdbcx::XTablesSupplier >
m_xMasterTables; // just to avoid the recreation of the catalog
connectivity::OWeakRefArray m_aStatements;
// contains OStatement and OPreparedStatement
std::vector<unotools::WeakReference<OStatementBase>>
m_aStatements;
rtl::Reference< OQueryContainer > m_xQueries;
connectivity::OWeakRefArray m_aComposers;