[Libreoffice-commits] core.git: connectivity/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Wed Mar 3 09:01:10 UTC 2021


 connectivity/source/drivers/postgresql/pq_connection.cxx          |   12 ++++-----
 connectivity/source/drivers/postgresql/pq_connection.hxx          |   13 ++++------
 connectivity/source/drivers/postgresql/pq_updateableresultset.cxx |    7 ++---
 connectivity/source/drivers/postgresql/pq_xcolumn.cxx             |    8 ++++--
 connectivity/source/drivers/postgresql/pq_xcolumns.cxx            |   10 +++----
 connectivity/source/drivers/postgresql/pq_xcolumns.hxx            |    4 ++-
 connectivity/source/drivers/postgresql/pq_xcontainer.hxx          |    6 +++-
 connectivity/source/drivers/postgresql/pq_xindex.cxx              |    5 ++-
 connectivity/source/drivers/postgresql/pq_xindexcolumn.cxx        |    8 ++++--
 connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx       |   10 +++----
 connectivity/source/drivers/postgresql/pq_xindexes.cxx            |    9 +++---
 connectivity/source/drivers/postgresql/pq_xkey.cxx                |    5 ++-
 connectivity/source/drivers/postgresql/pq_xkeycolumn.cxx          |    8 ++++--
 connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx         |   10 +++----
 connectivity/source/drivers/postgresql/pq_xkeys.cxx               |    8 +++---
 connectivity/source/drivers/postgresql/pq_xtable.cxx              |    8 +++---
 connectivity/source/drivers/postgresql/pq_xtable.hxx              |    2 -
 connectivity/source/drivers/postgresql/pq_xtables.cxx             |    8 +++---
 connectivity/source/drivers/postgresql/pq_xtables.hxx             |    8 +++++-
 connectivity/source/drivers/postgresql/pq_xuser.cxx               |    5 ++-
 connectivity/source/drivers/postgresql/pq_xusers.cxx              |    8 +++---
 connectivity/source/drivers/postgresql/pq_xview.cxx               |    5 ++-
 connectivity/source/drivers/postgresql/pq_xviews.cxx              |    8 +++---
 connectivity/source/drivers/postgresql/pq_xviews.hxx              |    8 +++++-
 24 files changed, 108 insertions(+), 75 deletions(-)

New commits:
commit 4f06d7cd74273e5691bb5a601452ea0e7eccffb3
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Tue Mar 2 13:45:06 2021 +0100
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Wed Mar 3 10:00:31 2021 +0100

    loplugin:refcounting (--enable-postgresql-sdbc)
    
    Change-Id: I79a1d05be3a4e7a8e278665ff5863cdc4b182009
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111832
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/connectivity/source/drivers/postgresql/pq_connection.cxx b/connectivity/source/drivers/postgresql/pq_connection.cxx
index 2bc1e4a42af8..9487e51def60 100644
--- a/connectivity/source/drivers/postgresql/pq_connection.cxx
+++ b/connectivity/source/drivers/postgresql/pq_connection.cxx
@@ -48,6 +48,7 @@
 #include "pq_xviews.hxx"
 #include "pq_xusers.hxx"
 
+#include <rtl/ref.hxx>
 #include <rtl/uuid.h>
 #include <sal/log.hxx>
 
@@ -186,13 +187,12 @@ Reference< XStatement > Connection::createStatement()
     MutexGuard guard( m_xMutex->GetMutex() );
     checkClosed();
 
-    Statement *stmt = new Statement( m_xMutex, this , &m_settings );
-    Reference< XStatement > ret( stmt );
+    rtl::Reference<Statement> stmt = new Statement( m_xMutex, this , &m_settings );
     ::rtl::ByteSequence id( 16 );
     rtl_createUuid( reinterpret_cast<sal_uInt8*>(id.getArray()), nullptr, false );
     m_myStatements[ id ] = Reference< XCloseable > ( stmt );
     stmt->queryAdapter()->addReference( new ClosableReference( id, this ) );
-    return ret;
+    return stmt;
 }
 
 Reference< XPreparedStatement > Connection::prepareStatement( const OUString& sql )
@@ -201,14 +201,14 @@ Reference< XPreparedStatement > Connection::prepareStatement( const OUString& sq
     checkClosed();
 
     OString byteSql = OUStringToOString( sql, ConnectionSettings::encoding );
-    PreparedStatement *stmt = new PreparedStatement( m_xMutex, this, &m_settings, byteSql );
-    Reference< XPreparedStatement > ret = stmt;
+    rtl::Reference<PreparedStatement> stmt
+        = new PreparedStatement( m_xMutex, this, &m_settings, byteSql );
 
     ::rtl::ByteSequence id( 16 );
     rtl_createUuid( reinterpret_cast<sal_uInt8*>(id.getArray()), nullptr, false );
     m_myStatements[ id ] = Reference< XCloseable > ( stmt );
     stmt->queryAdapter()->addReference( new ClosableReference( id, this ) );
-    return ret;
+    return stmt;
 }
 
 Reference< XPreparedStatement > Connection::prepareCall( const OUString& )
diff --git a/connectivity/source/drivers/postgresql/pq_connection.hxx b/connectivity/source/drivers/postgresql/pq_connection.hxx
index f8d19c406b18..a580d903f71f 100644
--- a/connectivity/source/drivers/postgresql/pq_connection.hxx
+++ b/connectivity/source/drivers/postgresql/pq_connection.hxx
@@ -61,19 +61,18 @@
 #include <libpq-fe.h>
 #include <unordered_map>
 
+#include "pq_xtables.hxx"
+#include "pq_xviews.hxx"
+
 namespace pq_sdbc_driver
 {
 struct ConnectionSettings;
-class Tables;
-class Views;
 struct ConnectionSettings
 {
     ConnectionSettings() :
         pConnection(nullptr),
         maxNameLen(0),
-        maxIndexKeys(0),
-        pTablesImpl(nullptr),
-        pViewsImpl(nullptr)
+        maxIndexKeys(0)
     {}
     static const rtl_TextEncoding encoding = RTL_TEXTENCODING_UTF8;
     PGconn *pConnection;
@@ -83,8 +82,8 @@ struct ConnectionSettings
     css::uno::Reference< css::container::XNameAccess > tables;
     css::uno::Reference< css::container::XNameAccess > users;
     css::uno::Reference< css::container::XNameAccess > views;
-    Tables *pTablesImpl;  // needed to implement renaming of tables / views
-    Views *pViewsImpl;   // needed to implement renaming of tables / views
+    rtl::Reference<Tables> pTablesImpl;  // needed to implement renaming of tables / views
+    rtl::Reference<Views> pViewsImpl;   // needed to implement renaming of tables / views
     OUString user;
     OUString catalog;
 };
diff --git a/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx b/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx
index d8780e76c563..8c5fdd3c8965 100644
--- a/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx
+++ b/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx
@@ -35,6 +35,7 @@
  ************************************************************************/
 
 #include <sal/log.hxx>
+#include <rtl/ref.hxx>
 #include <rtl/ustrbuf.hxx>
 
 #include <cppuhelper/queryinterface.hxx>
@@ -118,16 +119,14 @@ css::uno::Reference< css::sdbc::XCloseable > UpdateableResultSet::createFromPGRe
         data[row] = aRow;
     }
 
-    UpdateableResultSet *pRS =  new UpdateableResultSet(
+    rtl::Reference<UpdateableResultSet> pRS =  new UpdateableResultSet(
         mutex, owner, columnNames, data, ppSettings, schema, table, primaryKey );
 
-    Reference <XCloseable > ret = pRS; // give it a refcount
-
     pRS->m_meta = new ResultSetMetaData( mutex, pRS,nullptr, ppSettings, result, schema, table );
 
     PQclear( result ); // we don't need it anymore
 
-    return ret;
+    return pRS;
 }
 
 css::uno::Any  UpdateableResultSet::queryInterface(
diff --git a/connectivity/source/drivers/postgresql/pq_xcolumn.cxx b/connectivity/source/drivers/postgresql/pq_xcolumn.cxx
index c6d98b0fcb85..33e57a1a5445 100644
--- a/connectivity/source/drivers/postgresql/pq_xcolumn.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xcolumn.cxx
@@ -34,6 +34,10 @@
  *
  ************************************************************************/
 
+#include <sal/config.h>
+
+#include <rtl/ref.hxx>
+
 #include "pq_xcolumn.hxx"
 
 using com::sun::star::uno::Reference;
@@ -56,7 +60,7 @@ Column::Column( const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex
 
 Reference< XPropertySet > Column::createDataDescriptor(  )
 {
-    ColumnDescriptor * pColumn = new ColumnDescriptor(
+    rtl::Reference<ColumnDescriptor> pColumn = new ColumnDescriptor(
         m_xMutex, m_conn, m_pSettings );
     pColumn->copyValuesFrom( this );
     return Reference< XPropertySet > ( pColumn );
@@ -77,7 +81,7 @@ ColumnDescriptor::ColumnDescriptor(
 
 Reference< XPropertySet > ColumnDescriptor::createDataDescriptor(  )
 {
-    ColumnDescriptor * pColumn = new ColumnDescriptor(
+    rtl::Reference<ColumnDescriptor> pColumn = new ColumnDescriptor(
         m_xMutex, m_conn, m_pSettings );
     pColumn->copyValuesFrom( this );
 
diff --git a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx
index ed3af3579d2a..34d9ef38f36e 100644
--- a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx
@@ -34,6 +34,7 @@
  *
  ************************************************************************/
 
+#include <rtl/ref.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <sal/log.hxx>
 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
@@ -294,11 +295,11 @@ void Columns::refresh()
         int columnIndex = 0;
         while( rs->next() )
         {
-            Column * pColumn =
+            rtl::Reference<Column> pColumn =
                 new Column( m_xMutex, m_origin, m_pSettings );
             Reference< css::beans::XPropertySet > prop = pColumn;
 
-            OUString name = columnMetaData2SDBCX( pColumn, xRow );
+            OUString name = columnMetaData2SDBCX( pColumn.get(), xRow );
 //             pColumn->addPropertyChangeListener(
 //                 st.HELP_TEXT,
 //                 new CommentChanger(
@@ -526,14 +527,13 @@ Reference< css::container::XNameAccess > Columns::create(
     ConnectionSettings *pSettings,
     const OUString &schemaName,
     const OUString &tableName,
-    Columns **ppColumns)
+    rtl::Reference<Columns> *ppColumns)
 {
     *ppColumns = new Columns(
         refMutex, origin, pSettings, schemaName, tableName );
-    Reference< css::container::XNameAccess > ret = *ppColumns;
     (*ppColumns)->refresh();
 
-    return ret;
+    return *ppColumns;
 }
 
 
diff --git a/connectivity/source/drivers/postgresql/pq_xcolumns.hxx b/connectivity/source/drivers/postgresql/pq_xcolumns.hxx
index 78bb9770ebdf..e48c0529a56a 100644
--- a/connectivity/source/drivers/postgresql/pq_xcolumns.hxx
+++ b/connectivity/source/drivers/postgresql/pq_xcolumns.hxx
@@ -41,6 +41,8 @@
 
 #include <string_view>
 
+#include <rtl/ref.hxx>
+
 #include "pq_xcontainer.hxx"
 #include "pq_xbase.hxx"
 
@@ -72,7 +74,7 @@ public: // instances Columns 'exception safe'
         ConnectionSettings *pSettings,
         const OUString &schemaName,
         const OUString &tableName,
-        Columns **pColumns);
+        rtl::Reference<Columns> *pColumns);
 
 private:
     Columns(
diff --git a/connectivity/source/drivers/postgresql/pq_xcontainer.hxx b/connectivity/source/drivers/postgresql/pq_xcontainer.hxx
index f53b0303ae1b..085c2040634b 100644
--- a/connectivity/source/drivers/postgresql/pq_xcontainer.hxx
+++ b/connectivity/source/drivers/postgresql/pq_xcontainer.hxx
@@ -41,22 +41,26 @@
 #include <com/sun/star/container/XEnumerationAccess.hpp>
 #include <com/sun/star/container/XContainer.hpp>
 
+#include <com/sun/star/sdbc/XConnection.hpp>
 #include <com/sun/star/sdbcx/XAppend.hpp>
 #include <com/sun/star/sdbcx/XDrop.hpp>
 #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
 
 #include <com/sun/star/util/XRefreshable.hpp>
 
+#include <comphelper/refcountedmutex.hxx>
 #include <cppuhelper/compbase.hxx>
+#include <rtl/ref.hxx>
 
 #include <unordered_map>
 
-#include "pq_connection.hxx"
 #include "pq_statics.hxx"
 
 namespace pq_sdbc_driver
 {
 
+struct ConnectionSettings;
+
 class EventBroadcastHelper
 {
 public:
diff --git a/connectivity/source/drivers/postgresql/pq_xindex.cxx b/connectivity/source/drivers/postgresql/pq_xindex.cxx
index c340484a17df..5a96eeeb119d 100644
--- a/connectivity/source/drivers/postgresql/pq_xindex.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xindex.cxx
@@ -36,6 +36,7 @@
 
 #include <cppuhelper/typeprovider.hxx>
 #include <cppuhelper/queryinterface.hxx>
+#include <rtl/ref.hxx>
 
 #include "pq_xindex.hxx"
 #include "pq_xindexcolumns.hxx"
@@ -72,7 +73,7 @@ Index::Index( const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
 
 Reference< XPropertySet > Index::createDataDescriptor(  )
 {
-    IndexDescriptor * pIndex = new IndexDescriptor(
+    rtl::Reference<IndexDescriptor> pIndex = new IndexDescriptor(
         m_xMutex, m_conn, m_pSettings );
     pIndex->copyValuesFrom( this );
 
@@ -133,7 +134,7 @@ IndexDescriptor::IndexDescriptor(
 
 Reference< XPropertySet > IndexDescriptor::createDataDescriptor(  )
 {
-    IndexDescriptor * pIndex = new IndexDescriptor(
+    rtl::Reference<IndexDescriptor> pIndex = new IndexDescriptor(
         m_xMutex, m_conn, m_pSettings );
     pIndex->copyValuesFrom( this );
     return Reference< XPropertySet > ( pIndex );
diff --git a/connectivity/source/drivers/postgresql/pq_xindexcolumn.cxx b/connectivity/source/drivers/postgresql/pq_xindexcolumn.cxx
index 58b36234b1fb..58cae851f441 100644
--- a/connectivity/source/drivers/postgresql/pq_xindexcolumn.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xindexcolumn.cxx
@@ -34,6 +34,10 @@
  *
  ************************************************************************/
 
+#include <sal/config.h>
+
+#include <rtl/ref.hxx>
+
 #include "pq_xindexcolumn.hxx"
 
 using com::sun::star::uno::Reference;
@@ -56,7 +60,7 @@ IndexColumn::IndexColumn( const ::rtl::Reference< comphelper::RefCountedMutex >
 
 Reference< XPropertySet > IndexColumn::createDataDescriptor(  )
 {
-    IndexColumnDescriptor * pIndexColumn = new IndexColumnDescriptor(
+    rtl::Reference<IndexColumnDescriptor> pIndexColumn = new IndexColumnDescriptor(
         m_xMutex, m_conn, m_pSettings  );
     pIndexColumn->copyValuesFrom( this );
 
@@ -79,7 +83,7 @@ IndexColumnDescriptor::IndexColumnDescriptor(
 
 Reference< XPropertySet > IndexColumnDescriptor::createDataDescriptor(  )
 {
-    IndexColumnDescriptor * pIndexColumn = new IndexColumnDescriptor(
+    rtl::Reference<IndexColumnDescriptor> pIndexColumn = new IndexColumnDescriptor(
         m_xMutex, m_conn, m_pSettings  );
     pIndexColumn->copyValuesFrom( this );
 
diff --git a/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx b/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx
index a16d22d0cf2f..1e0039ecc6e1 100644
--- a/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx
@@ -43,6 +43,7 @@
 #include <com/sun/star/sdbc/SQLException.hpp>
 #include <com/sun/star/sdbc/XRow.hpp>
 #include <cppuhelper/exc_hlp.hxx>
+#include <rtl/ref.hxx>
 
 #include "pq_xcolumns.hxx"
 #include "pq_xindexcolumns.hxx"
@@ -124,11 +125,11 @@ void IndexColumns::refresh()
             if( index >= m_columns.getLength() )
                 continue;
 
-            IndexColumn * pIndexColumn =
+            rtl::Reference<IndexColumn> pIndexColumn =
                 new IndexColumn( m_xMutex, m_origin, m_pSettings );
             Reference< css::beans::XPropertySet > prop = pIndexColumn;
 
-            columnMetaData2SDBCX( pIndexColumn, xRow );
+            columnMetaData2SDBCX( pIndexColumn.get(), xRow );
             pIndexColumn->setPropertyValue_NoBroadcast_public(
                 st.IS_ASCENDING , makeAny( false ) );
 
@@ -234,12 +235,11 @@ Reference< css::container::XNameAccess > IndexColumns::create(
     const OUString &indexName,
     const Sequence< OUString > &columns )
 {
-    IndexColumns *pIndexColumns = new IndexColumns(
+    rtl::Reference<IndexColumns> pIndexColumns = new IndexColumns(
         refMutex, origin, pSettings, schemaName, tableName, indexName, columns );
-    Reference< css::container::XNameAccess > ret = pIndexColumns;
     pIndexColumns->refresh();
 
-    return ret;
+    return pIndexColumns;
 }
 
 
diff --git a/connectivity/source/drivers/postgresql/pq_xindexes.cxx b/connectivity/source/drivers/postgresql/pq_xindexes.cxx
index 2f6df914f0a2..5f97fed9510a 100644
--- a/connectivity/source/drivers/postgresql/pq_xindexes.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xindexes.cxx
@@ -35,6 +35,7 @@
  ************************************************************************/
 
 #include <sal/log.hxx>
+#include <rtl/ref.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
@@ -133,7 +134,7 @@ void Indexes::refresh()
             static const sal_Int32 C_IS_PRIMARY = 6;
             static const sal_Int32 C_COLUMNS = 7;
             OUString currentIndexName = row->getString( C_INDEXNAME );
-            Index *pIndex =
+            rtl::Reference<Index> pIndex =
                 new Index( m_xMutex, m_origin, m_pSettings,
                            m_schemaName, m_tableName );
 
@@ -268,10 +269,10 @@ Reference< css::container::XNameAccess > Indexes::create(
     const OUString & schemaName,
     const OUString & tableName)
 {
-    Indexes *pIndexes = new Indexes( refMutex, origin, pSettings, schemaName, tableName );
-    Reference< css::container::XNameAccess > ret = pIndexes;
+    rtl::Reference<Indexes> pIndexes
+        = new Indexes( refMutex, origin, pSettings, schemaName, tableName );
     pIndexes->refresh();
-    return ret;
+    return pIndexes;
 }
 
 
diff --git a/connectivity/source/drivers/postgresql/pq_xkey.cxx b/connectivity/source/drivers/postgresql/pq_xkey.cxx
index ed0b2669e894..e2777824568f 100644
--- a/connectivity/source/drivers/postgresql/pq_xkey.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xkey.cxx
@@ -36,6 +36,7 @@
 
 #include <cppuhelper/typeprovider.hxx>
 #include <cppuhelper/queryinterface.hxx>
+#include <rtl/ref.hxx>
 
 #include "pq_xkey.hxx"
 #include "pq_xkeycolumns.hxx"
@@ -71,7 +72,7 @@ Key::Key( const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
 
 Reference< XPropertySet > Key::createDataDescriptor(  )
 {
-    KeyDescriptor * pKeyDescriptor = new KeyDescriptor(
+    rtl::Reference<KeyDescriptor> pKeyDescriptor = new KeyDescriptor(
         m_xMutex, m_conn, m_pSettings );
     pKeyDescriptor->copyValuesFrom( this );
 
@@ -134,7 +135,7 @@ KeyDescriptor::KeyDescriptor( const ::rtl::Reference< comphelper::RefCountedMute
 
 Reference< XPropertySet > KeyDescriptor::createDataDescriptor(  )
 {
-    KeyDescriptor * pKeyDescriptor = new KeyDescriptor(
+    rtl::Reference<KeyDescriptor> pKeyDescriptor = new KeyDescriptor(
         m_xMutex, m_conn, m_pSettings );
     pKeyDescriptor->copyValuesFrom( this );
 
diff --git a/connectivity/source/drivers/postgresql/pq_xkeycolumn.cxx b/connectivity/source/drivers/postgresql/pq_xkeycolumn.cxx
index 9eea45204f3d..10c3dbb474cd 100644
--- a/connectivity/source/drivers/postgresql/pq_xkeycolumn.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xkeycolumn.cxx
@@ -34,6 +34,10 @@
  *
  ************************************************************************/
 
+#include <sal/config.h>
+
+#include <rtl/ref.hxx>
+
 #include "pq_xkeycolumn.hxx"
 
 using com::sun::star::uno::Reference;
@@ -56,7 +60,7 @@ KeyColumn::KeyColumn( const ::rtl::Reference< comphelper::RefCountedMutex > & re
 
 Reference< XPropertySet > KeyColumn::createDataDescriptor(  )
 {
-    KeyColumnDescriptor * pKeyColumn = new KeyColumnDescriptor(
+    rtl::Reference<KeyColumnDescriptor> pKeyColumn = new KeyColumnDescriptor(
         m_xMutex, m_conn, m_pSettings );
     pKeyColumn->copyValuesFrom( this );
 
@@ -78,7 +82,7 @@ KeyColumnDescriptor::KeyColumnDescriptor(
 
 Reference< XPropertySet > KeyColumnDescriptor::createDataDescriptor(  )
 {
-    KeyColumnDescriptor * pKeyColumn = new KeyColumnDescriptor(
+    rtl::Reference<KeyColumnDescriptor> pKeyColumn = new KeyColumnDescriptor(
         m_xMutex, m_conn, m_pSettings );
     pKeyColumn->copyValuesFrom( this );
 
diff --git a/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx b/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx
index 890b57fa7420..6dcbe07d4117 100644
--- a/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx
@@ -39,6 +39,7 @@
 #include <com/sun/star/sdbc/SQLException.hpp>
 #include <com/sun/star/sdbc/XRow.hpp>
 #include <cppuhelper/exc_hlp.hxx>
+#include <rtl/ref.hxx>
 
 #include "pq_xcolumns.hxx"
 #include "pq_xkeycolumns.hxx"
@@ -117,11 +118,11 @@ void KeyColumns::refresh()
             if( m_columnNames.getLength() == keyindex )
                 continue;
 
-            KeyColumn * pKeyColumn =
+            rtl::Reference<KeyColumn> pKeyColumn =
                 new KeyColumn( m_xMutex, m_origin, m_pSettings );
             Reference< css::beans::XPropertySet > prop = pKeyColumn;
 
-            OUString name = columnMetaData2SDBCX( pKeyColumn, xRow );
+            OUString name = columnMetaData2SDBCX( pKeyColumn.get(), xRow );
             if( keyindex < m_foreignColumnNames.getLength() )
             {
                 pKeyColumn->setPropertyValue_NoBroadcast_public(
@@ -214,12 +215,11 @@ Reference< css::container::XNameAccess > KeyColumns::create(
     const Sequence< OUString > &columnNames ,
     const Sequence< OUString > &foreignColumnNames )
 {
-    KeyColumns *pKeyColumns = new KeyColumns(
+    rtl::Reference<KeyColumns> pKeyColumns = new KeyColumns(
         refMutex, origin, pSettings, schemaName, tableName, columnNames, foreignColumnNames );
-    Reference< css::container::XNameAccess > ret = pKeyColumns;
     pKeyColumns->refresh();
 
-    return ret;
+    return pKeyColumns;
 }
 
 
diff --git a/connectivity/source/drivers/postgresql/pq_xkeys.cxx b/connectivity/source/drivers/postgresql/pq_xkeys.cxx
index 969ce4dd398c..88d8b5b1189b 100644
--- a/connectivity/source/drivers/postgresql/pq_xkeys.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xkeys.cxx
@@ -39,6 +39,7 @@
 #include <string_view>
 
 #include <sal/log.hxx>
+#include <rtl/ref.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
@@ -150,7 +151,7 @@ void Keys::refresh()
         int keyIndex = 0;
         while( rs->next() )
         {
-            Key * pKey =
+            rtl::Reference<Key> pKey =
                 new Key( m_xMutex, m_origin, m_pSettings , m_schemaName, m_tableName );
             Reference< css::beans::XPropertySet > prop = pKey;
 
@@ -262,11 +263,10 @@ Reference< css::container::XIndexAccess > Keys::create(
     const OUString & schemaName,
     const OUString & tableName)
 {
-    Keys *pKeys = new Keys( refMutex, origin, pSettings, schemaName, tableName );
-    Reference< css::container::XIndexAccess > ret = pKeys;
+    rtl::Reference<Keys> pKeys = new Keys( refMutex, origin, pSettings, schemaName, tableName );
     pKeys->refresh();
 
-    return ret;
+    return pKeys;
 }
 
 KeyDescriptors::KeyDescriptors(
diff --git a/connectivity/source/drivers/postgresql/pq_xtable.cxx b/connectivity/source/drivers/postgresql/pq_xtable.cxx
index 82b66a316a3f..9ac52f1df0ff 100644
--- a/connectivity/source/drivers/postgresql/pq_xtable.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xtable.cxx
@@ -34,6 +34,7 @@
  *
  ************************************************************************/
 
+#include <rtl/ref.hxx>
 #include <rtl/ustrbuf.hxx>
 
 #include <cppuhelper/typeprovider.hxx>
@@ -78,13 +79,12 @@ Table::Table( const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
         refMutex,
         connection,
         pSettings,
-        * getStatics().refl.table.pProps ),
-      m_pColumns( nullptr )
+        * getStatics().refl.table.pProps )
 {}
 
 Reference< XPropertySet > Table::createDataDescriptor(  )
 {
-    TableDescriptor * pTable = new TableDescriptor(
+    rtl::Reference<TableDescriptor> pTable = new TableDescriptor(
         m_xMutex, m_conn, m_pSettings );
     pTable->copyValuesFrom( this );
 
@@ -381,7 +381,7 @@ Any TableDescriptor::queryInterface( const Type & reqType )
 
 Reference< XPropertySet > TableDescriptor::createDataDescriptor(  )
 {
-    TableDescriptor * pTable = new TableDescriptor(
+    rtl::Reference<TableDescriptor> pTable = new TableDescriptor(
         m_xMutex, m_conn, m_pSettings );
 
     // TODO: deep copies
diff --git a/connectivity/source/drivers/postgresql/pq_xtable.hxx b/connectivity/source/drivers/postgresql/pq_xtable.hxx
index 69e9d6435c8a..440589381755 100644
--- a/connectivity/source/drivers/postgresql/pq_xtable.hxx
+++ b/connectivity/source/drivers/postgresql/pq_xtable.hxx
@@ -66,7 +66,7 @@ class Table : public ReflectionBase,
     css::uno::Reference< css::container::XNameAccess > m_columns;
     css::uno::Reference< css::container::XIndexAccess > m_keys;
     css::uno::Reference< css::container::XNameAccess > m_indexes;
-    Columns *m_pColumns;
+    rtl::Reference<Columns> m_pColumns;
 
 public:
     Table( const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
diff --git a/connectivity/source/drivers/postgresql/pq_xtables.cxx b/connectivity/source/drivers/postgresql/pq_xtables.cxx
index 83758208b203..47606669dd40 100644
--- a/connectivity/source/drivers/postgresql/pq_xtables.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xtables.cxx
@@ -34,6 +34,7 @@
  *
  ************************************************************************/
 
+#include <rtl/ref.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
@@ -103,7 +104,7 @@ void Tables::refresh()
         {
             // if creating all these tables turns out to have too bad performance, we might
             // instead offer a factory interface
-            Table * pTable =
+            rtl::Reference<Table> pTable =
                 new Table( m_xMutex, m_origin, m_pSettings );
             Reference< css::beans::XPropertySet > prop = pTable;
 
@@ -355,13 +356,12 @@ Reference< css::container::XNameAccess > Tables::create(
     const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
     const css::uno::Reference< css::sdbc::XConnection >  & origin,
     ConnectionSettings *pSettings,
-    Tables **ppTables)
+    rtl::Reference<Tables> *ppTables)
 {
     *ppTables = new Tables( refMutex, origin, pSettings );
-    Reference< css::container::XNameAccess > ret = *ppTables;
     (*ppTables)->refresh();
 
-    return ret;
+    return *ppTables;
 }
 
 };
diff --git a/connectivity/source/drivers/postgresql/pq_xtables.hxx b/connectivity/source/drivers/postgresql/pq_xtables.hxx
index 33eab3a5b8c4..827fc3a28ee8 100644
--- a/connectivity/source/drivers/postgresql/pq_xtables.hxx
+++ b/connectivity/source/drivers/postgresql/pq_xtables.hxx
@@ -37,11 +37,17 @@
 #ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_POSTGRESQL_PQ_XTABLES_HXX
 #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_POSTGRESQL_PQ_XTABLES_HXX
 
+#include <sal/config.h>
+
+#include <rtl/ref.hxx>
+
 #include "pq_xcontainer.hxx"
 
 namespace pq_sdbc_driver
 {
 
+struct ConnectionSettings;
+
 class Tables : public Container
 {
 
@@ -50,7 +56,7 @@ public: // instances Tables 'exception safe'
         const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
         const css::uno::Reference< css::sdbc::XConnection >  & origin,
         ConnectionSettings *pSettings,
-        Tables ** ppTables);
+        rtl::Reference<Tables> * ppTables);
 
 protected:
     Tables(
diff --git a/connectivity/source/drivers/postgresql/pq_xuser.cxx b/connectivity/source/drivers/postgresql/pq_xuser.cxx
index bc06c541064e..4d0a01f6366f 100644
--- a/connectivity/source/drivers/postgresql/pq_xuser.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xuser.cxx
@@ -35,6 +35,7 @@
  ************************************************************************/
 
 #include <sal/log.hxx>
+#include <rtl/ref.hxx>
 #include <rtl/ustrbuf.hxx>
 
 #include <cppuhelper/typeprovider.hxx>
@@ -73,7 +74,7 @@ User::User( const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
 
 Reference< XPropertySet > User::createDataDescriptor(  )
 {
-    UserDescriptor * pUser = new UserDescriptor( m_xMutex, m_conn, m_pSettings );
+    rtl::Reference<UserDescriptor> pUser = new UserDescriptor( m_xMutex, m_conn, m_pSettings );
     pUser->copyValuesFrom( this );
 
     return Reference< XPropertySet > ( pUser );
@@ -159,7 +160,7 @@ UserDescriptor::UserDescriptor(
 
 Reference< XPropertySet > UserDescriptor::createDataDescriptor(  )
 {
-    UserDescriptor * pUser = new UserDescriptor( m_xMutex, m_conn, m_pSettings );
+    rtl::Reference<UserDescriptor> pUser = new UserDescriptor( m_xMutex, m_conn, m_pSettings );
     pUser->copyValuesFrom( this );
 
     return Reference< XPropertySet > ( pUser );
diff --git a/connectivity/source/drivers/postgresql/pq_xusers.cxx b/connectivity/source/drivers/postgresql/pq_xusers.cxx
index a6fe3489fa7f..bc8b62b1d5b4 100644
--- a/connectivity/source/drivers/postgresql/pq_xusers.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xusers.cxx
@@ -34,6 +34,7 @@
  *
  ************************************************************************/
 
+#include <rtl/ref.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
@@ -91,7 +92,7 @@ void Users::refresh()
         sal_Int32 tableIndex = 0;
         while( rs->next() )
         {
-            User * pUser =
+            rtl::Reference<User> pUser =
                 new User( m_xMutex, m_origin, m_pSettings );
             Reference< css::beans::XPropertySet > prop = pUser;
 
@@ -185,11 +186,10 @@ Reference< css::container::XNameAccess > Users::create(
     const css::uno::Reference< css::sdbc::XConnection >  & origin,
     ConnectionSettings *pSettings )
 {
-    Users *pUsers = new Users( refMutex, origin, pSettings );
-    Reference< css::container::XNameAccess > ret = pUsers;
+    rtl::Reference<Users> pUsers = new Users( refMutex, origin, pSettings );
     pUsers->refresh();
 
-    return ret;
+    return pUsers;
 }
 
 void Users::disposing()
diff --git a/connectivity/source/drivers/postgresql/pq_xview.cxx b/connectivity/source/drivers/postgresql/pq_xview.cxx
index 1b00b9b5d326..3652cdee634f 100644
--- a/connectivity/source/drivers/postgresql/pq_xview.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xview.cxx
@@ -34,6 +34,7 @@
  *
  ************************************************************************/
 
+#include <rtl/ref.hxx>
 #include <rtl/ustrbuf.hxx>
 
 #include <cppuhelper/typeprovider.hxx>
@@ -76,7 +77,7 @@ View::View( const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
 
 Reference< XPropertySet > View::createDataDescriptor(  )
 {
-    ViewDescriptor * pView = new ViewDescriptor(
+    rtl::Reference<ViewDescriptor> pView = new ViewDescriptor(
         m_xMutex, m_conn, m_pSettings );
     pView->copyValuesFrom( this );
 
@@ -205,7 +206,7 @@ ViewDescriptor::ViewDescriptor(
 
 Reference< XPropertySet > ViewDescriptor::createDataDescriptor(  )
 {
-    ViewDescriptor * pView = new ViewDescriptor(
+    rtl::Reference<ViewDescriptor> pView = new ViewDescriptor(
         m_xMutex, m_conn, m_pSettings );
     pView->copyValuesFrom( this );
 
diff --git a/connectivity/source/drivers/postgresql/pq_xviews.cxx b/connectivity/source/drivers/postgresql/pq_xviews.cxx
index ac684a16c124..3f36c168b6d2 100644
--- a/connectivity/source/drivers/postgresql/pq_xviews.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xviews.cxx
@@ -34,6 +34,7 @@
  *
  ************************************************************************/
 
+#include <rtl/ref.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
@@ -106,7 +107,7 @@ void Views::refresh()
             table = xRow->getString( 2 );
             command = xRow->getString( 3 );
 
-            View *pView = new View (m_xMutex, m_origin, m_pSettings );
+            rtl::Reference<View> pView = new View (m_xMutex, m_origin, m_pSettings );
             Reference< css::beans::XPropertySet > prop = pView;
 
             pView->setPropertyValue_NoBroadcast_public(st.NAME , makeAny(table) );
@@ -204,13 +205,12 @@ Reference< css::container::XNameAccess > Views::create(
     const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
     const css::uno::Reference< css::sdbc::XConnection >  & origin,
     ConnectionSettings *pSettings,
-    Views **ppViews)
+    rtl::Reference<Views> *ppViews)
 {
     *ppViews = new Views( refMutex, origin, pSettings );
-    Reference< css::container::XNameAccess > ret = *ppViews;
     (*ppViews)->refresh();
 
-    return ret;
+    return *ppViews;
 }
 
 };
diff --git a/connectivity/source/drivers/postgresql/pq_xviews.hxx b/connectivity/source/drivers/postgresql/pq_xviews.hxx
index 5ce5b879bd0e..31159a9e379f 100644
--- a/connectivity/source/drivers/postgresql/pq_xviews.hxx
+++ b/connectivity/source/drivers/postgresql/pq_xviews.hxx
@@ -37,11 +37,17 @@
 #ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_POSTGRESQL_PQ_XVIEWS_HXX
 #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_POSTGRESQL_PQ_XVIEWS_HXX
 
+#include <sal/config.h>
+
+#include <rtl/ref.hxx>
+
 #include "pq_xcontainer.hxx"
 
 namespace pq_sdbc_driver
 {
 
+struct ConnectionSettings;
+
 class Views : public Container
 {
 
@@ -50,7 +56,7 @@ public: // instances Views 'exception safe'
         const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
         const css::uno::Reference< css::sdbc::XConnection >  & origin,
         ConnectionSettings *pSettings,
-        Views **ppViews );
+        rtl::Reference<Views> *ppViews );
 
 protected:
     Views(


More information about the Libreoffice-commits mailing list