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

Noel Grandin noel.grandin at collabora.co.uk
Mon Jan 29 06:21:37 UTC 2018


 connectivity/source/drivers/ado/ACatalog.cxx       |    8 ++++----
 connectivity/source/drivers/calc/CCatalog.cxx      |    2 +-
 connectivity/source/drivers/dbase/DCatalog.cxx     |    2 +-
 connectivity/source/drivers/evoab2/NCatalog.cxx    |    4 ++--
 connectivity/source/drivers/file/FCatalog.cxx      |    2 +-
 connectivity/source/drivers/firebird/Catalog.cxx   |    8 ++++----
 connectivity/source/drivers/flat/ECatalog.cxx      |    2 +-
 connectivity/source/drivers/hsqldb/HCatalog.cxx    |    6 +++---
 connectivity/source/drivers/macab/MacabCatalog.cxx |    4 ++--
 connectivity/source/drivers/mork/MCatalog.cxx      |    4 ++--
 connectivity/source/drivers/mysql/YCatalog.cxx     |    6 +++---
 connectivity/source/drivers/writer/WCatalog.cxx    |    2 +-
 connectivity/source/inc/ado/ACatalog.hxx           |    2 +-
 connectivity/source/inc/hsqldb/HCatalog.hxx        |    4 ++--
 connectivity/source/inc/mysql/YCatalog.hxx         |    4 ++--
 connectivity/source/sdbcx/VCatalog.cxx             |   12 ++++--------
 include/connectivity/sdbcx/VCatalog.hxx            |    9 +++++----
 17 files changed, 39 insertions(+), 42 deletions(-)

New commits:
commit 53d21a31435c6fc781fe34400e18abb34a6b04d8
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Jan 23 16:55:44 2018 +0200

    loplugin:useuniqueptr in OCatalog
    
    Change-Id: Ie06456ac8971494f64711cd70fd2b32a4dce719d
    Reviewed-on: https://gerrit.libreoffice.org/48740
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/connectivity/source/drivers/ado/ACatalog.cxx b/connectivity/source/drivers/ado/ACatalog.cxx
index cb44200f7920..5e80bedbc031 100644
--- a/connectivity/source/drivers/ado/ACatalog.cxx
+++ b/connectivity/source/drivers/ado/ACatalog.cxx
@@ -69,7 +69,7 @@ void OCatalog::refreshTables()
     if(m_pTables)
         m_pTables->reFill(aVector);
     else
-        m_pTables = new OTables(this,m_aMutex,aVector,aTables,m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers());
+        m_pTables.reset( new OTables(this,m_aMutex,aVector,aTables,m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers()) );
 }
 
 void OCatalog::refreshViews()
@@ -82,7 +82,7 @@ void OCatalog::refreshViews()
     if(m_pViews)
         m_pViews->reFill(aVector);
     else
-        m_pViews = new OViews(this,m_aMutex,aVector,aViews,m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers());
+        m_pViews.reset( new OViews(this,m_aMutex,aVector,aViews,m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers()) );
 }
 
 void OCatalog::refreshGroups()
@@ -95,7 +95,7 @@ void OCatalog::refreshGroups()
     if(m_pGroups)
         m_pGroups->reFill(aVector);
     else
-        m_pGroups = new OGroups(this,m_aMutex,aVector,aGroups,m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers());
+        m_pGroups.reset( new OGroups(this,m_aMutex,aVector,aGroups,m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers()) );
 }
 
 void OCatalog::refreshUsers()
@@ -108,7 +108,7 @@ void OCatalog::refreshUsers()
     if(m_pUsers)
         m_pUsers->reFill(aVector);
     else
-        m_pUsers = new OUsers(this,m_aMutex,aVector,aUsers,m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers());
+        m_pUsers.reset( new OUsers(this,m_aMutex,aVector,aUsers,m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers()) );
 }
 
 
diff --git a/connectivity/source/drivers/calc/CCatalog.cxx b/connectivity/source/drivers/calc/CCatalog.cxx
index 7ac5af5398d4..6853a5f9dbc3 100644
--- a/connectivity/source/drivers/calc/CCatalog.cxx
+++ b/connectivity/source/drivers/calc/CCatalog.cxx
@@ -53,7 +53,7 @@ void OCalcCatalog::refreshTables()
     if(m_pTables)
         m_pTables->reFill(aVector);
     else
-        m_pTables = new OCalcTables(m_xMetaData,*this,m_aMutex,aVector);
+        m_pTables.reset( new OCalcTables(m_xMetaData,*this,m_aMutex,aVector) );
 
     // this avoids that the document will be loaded a 2nd time when one table will be accessed.
     //if ( m_pTables && m_pTables->hasElements() )
diff --git a/connectivity/source/drivers/dbase/DCatalog.cxx b/connectivity/source/drivers/dbase/DCatalog.cxx
index 8bc06bb98141..c35af1f28e62 100644
--- a/connectivity/source/drivers/dbase/DCatalog.cxx
+++ b/connectivity/source/drivers/dbase/DCatalog.cxx
@@ -52,7 +52,7 @@ void ODbaseCatalog::refreshTables()
     if(m_pTables)
         m_pTables->reFill(aVector);
     else
-        m_pTables = new ODbaseTables(m_xMetaData,*this,m_aMutex,aVector);
+        m_pTables.reset( new ODbaseTables(m_xMetaData,*this,m_aMutex,aVector) );
 }
 
 
diff --git a/connectivity/source/drivers/evoab2/NCatalog.cxx b/connectivity/source/drivers/evoab2/NCatalog.cxx
index 1d8c2924a081..fb010b8dce5d 100644
--- a/connectivity/source/drivers/evoab2/NCatalog.cxx
+++ b/connectivity/source/drivers/evoab2/NCatalog.cxx
@@ -58,7 +58,7 @@ void OEvoabCatalog::refreshTables()
     if(m_pTables)
         m_pTables->reFill(aVector);
     else
-        m_pTables = new OEvoabTables(m_xMetaData,*this,m_aMutex,aVector);
+        m_pTables.reset( new OEvoabTables(m_xMetaData,*this,m_aMutex,aVector) );
 }
 // XTablesSupplier
 Reference< XNameAccess > SAL_CALL  OEvoabCatalog::getTables(  )
@@ -81,7 +81,7 @@ Reference< XNameAccess > SAL_CALL  OEvoabCatalog::getTables(  )
                 // allowed
         }
 
-        return m_pTables;
+        return m_pTables.get();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/file/FCatalog.cxx b/connectivity/source/drivers/file/FCatalog.cxx
index fbac414461e6..d617fdbfd774 100644
--- a/connectivity/source/drivers/file/FCatalog.cxx
+++ b/connectivity/source/drivers/file/FCatalog.cxx
@@ -62,7 +62,7 @@ void OFileCatalog::refreshTables()
     if(m_pTables)
         m_pTables->reFill(aVector);
     else
-        m_pTables = new OTables(m_xMetaData,*this,m_aMutex,aVector);
+        m_pTables.reset( new OTables(m_xMetaData,*this,m_aMutex,aVector) );
 }
 
 
diff --git a/connectivity/source/drivers/firebird/Catalog.cxx b/connectivity/source/drivers/firebird/Catalog.cxx
index 69329af63500..c9fc63486dc4 100644
--- a/connectivity/source/drivers/firebird/Catalog.cxx
+++ b/connectivity/source/drivers/firebird/Catalog.cxx
@@ -43,10 +43,10 @@ void Catalog::refreshTables()
     fillNames(xTables, aTableNames);
 
     if (!m_pTables)
-        m_pTables = new Tables(m_xConnection->getMetaData(),
+        m_pTables.reset( new Tables(m_xConnection->getMetaData(),
                                *this,
                                m_aMutex,
-                               aTableNames);
+                               aTableNames) );
     else
         m_pTables->reFill(aTableNames);
 
@@ -84,10 +84,10 @@ void Catalog::refreshUsers()
     }
 
     if (!m_pUsers)
-        m_pUsers = new Users(m_xConnection->getMetaData(),
+        m_pUsers.reset( new Users(m_xConnection->getMetaData(),
                              *this,
                              m_aMutex,
-                             aUserNames);
+                             aUserNames) );
     else
         m_pUsers->reFill(aUserNames);
 }
diff --git a/connectivity/source/drivers/flat/ECatalog.cxx b/connectivity/source/drivers/flat/ECatalog.cxx
index 2317722501b5..b656b29c21b8 100644
--- a/connectivity/source/drivers/flat/ECatalog.cxx
+++ b/connectivity/source/drivers/flat/ECatalog.cxx
@@ -53,7 +53,7 @@ void OFlatCatalog::refreshTables()
     if(m_pTables)
         m_pTables->reFill(aVector);
     else
-        m_pTables = new OFlatTables(m_xMetaData,*this,m_aMutex,aVector);
+        m_pTables.reset( new OFlatTables(m_xMetaData,*this,m_aMutex,aVector) );
 }
 
 
diff --git a/connectivity/source/drivers/hsqldb/HCatalog.cxx b/connectivity/source/drivers/hsqldb/HCatalog.cxx
index a96ee12bcc8c..9824ead35dc8 100644
--- a/connectivity/source/drivers/hsqldb/HCatalog.cxx
+++ b/connectivity/source/drivers/hsqldb/HCatalog.cxx
@@ -63,7 +63,7 @@ void OHCatalog::refreshTables()
     if ( m_pTables )
         m_pTables->reFill(aVector);
     else
-        m_pTables = new OTables(m_xMetaData,*this,m_aMutex,aVector);
+        m_pTables.reset( new OTables(m_xMetaData,*this,m_aMutex,aVector) );
 }
 
 void OHCatalog::refreshViews()
@@ -94,7 +94,7 @@ void OHCatalog::refreshViews()
     if ( m_pViews )
         m_pViews->reFill(aVector);
     else
-        m_pViews = new HViews( m_xConnection, *this, m_aMutex, aVector );
+        m_pViews.reset( new HViews( m_xConnection, *this, m_aMutex, aVector ) );
 }
 
 void OHCatalog::refreshGroups()
@@ -118,7 +118,7 @@ void OHCatalog::refreshUsers()
     if(m_pUsers)
         m_pUsers->reFill(aVector);
     else
-        m_pUsers = new OUsers(*this,m_aMutex,aVector,m_xConnection,this);
+        m_pUsers.reset( new OUsers(*this,m_aMutex,aVector,m_xConnection,this) );
 }
 
 Any SAL_CALL OHCatalog::queryInterface( const Type & rType )
diff --git a/connectivity/source/drivers/macab/MacabCatalog.cxx b/connectivity/source/drivers/macab/MacabCatalog.cxx
index 7d613d8a007d..d972bb137cc7 100644
--- a/connectivity/source/drivers/macab/MacabCatalog.cxx
+++ b/connectivity/source/drivers/macab/MacabCatalog.cxx
@@ -62,7 +62,7 @@ void MacabCatalog::refreshTables()
     if (m_pTables)
         m_pTables->reFill(aVector);
     else
-        m_pTables = new MacabTables(m_xMetaData,*this,m_aMutex,aVector);
+        m_pTables.reset( new MacabTables(m_xMetaData,*this,m_aMutex,aVector) );
 }
 
 void MacabCatalog::refreshViews()
@@ -105,7 +105,7 @@ Reference< XNameAccess > SAL_CALL MacabCatalog::getTables(  )
         // allowed
     }
 
-    return m_pTables;
+    return m_pTables.get();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mork/MCatalog.cxx b/connectivity/source/drivers/mork/MCatalog.cxx
index 0322036f7f58..80eb293a5c02 100644
--- a/connectivity/source/drivers/mork/MCatalog.cxx
+++ b/connectivity/source/drivers/mork/MCatalog.cxx
@@ -59,7 +59,7 @@ void OCatalog::refreshTables()
     if(m_pTables)
         m_pTables->reFill(aVector);
     else
-        m_pTables = new OTables(m_xMetaData,*this,m_aMutex,aVector);
+        m_pTables.reset( new OTables(m_xMetaData,*this,m_aMutex,aVector) );
 }
 
 void OCatalog::refreshViews()
@@ -96,7 +96,7 @@ Reference< XNameAccess > SAL_CALL OCatalog::getTables(  )
         // allowed
     }
 
-    return m_pTables;
+    return m_pTables.get();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mysql/YCatalog.cxx b/connectivity/source/drivers/mysql/YCatalog.cxx
index 364c4ce80607..020085c9141a 100644
--- a/connectivity/source/drivers/mysql/YCatalog.cxx
+++ b/connectivity/source/drivers/mysql/YCatalog.cxx
@@ -64,7 +64,7 @@ void OMySQLCatalog::refreshTables()
     if ( m_pTables )
         m_pTables->reFill(aVector);
     else
-        m_pTables = new OTables(m_xMetaData,*this,m_aMutex,aVector);
+        m_pTables.reset( new OTables(m_xMetaData,*this,m_aMutex,aVector) );
 }
 
 void OMySQLCatalog::refreshViews()
@@ -81,7 +81,7 @@ void OMySQLCatalog::refreshViews()
     if ( m_pViews )
         m_pViews->reFill(aVector);
     else
-        m_pViews = new OViews(m_xMetaData,*this,m_aMutex,aVector);
+        m_pViews.reset( new OViews(m_xMetaData,*this,m_aMutex,aVector) );
 }
 
 void OMySQLCatalog::refreshGroups()
@@ -105,7 +105,7 @@ void OMySQLCatalog::refreshUsers()
     if(m_pUsers)
         m_pUsers->reFill(aVector);
     else
-        m_pUsers = new OUsers(*this,m_aMutex,aVector,m_xConnection,this);
+        m_pUsers.reset( new OUsers(*this,m_aMutex,aVector,m_xConnection,this) );
 }
 
 Any SAL_CALL OMySQLCatalog::queryInterface( const Type & rType )
diff --git a/connectivity/source/drivers/writer/WCatalog.cxx b/connectivity/source/drivers/writer/WCatalog.cxx
index 36b571c24c96..ce95004cc668 100644
--- a/connectivity/source/drivers/writer/WCatalog.cxx
+++ b/connectivity/source/drivers/writer/WCatalog.cxx
@@ -54,7 +54,7 @@ void OWriterCatalog::refreshTables()
     if (m_pTables)
         m_pTables->reFill(aVector);
     else
-        m_pTables = new OWriterTables(m_xMetaData, *this, m_aMutex, aVector);
+        m_pTables.reset( new OWriterTables(m_xMetaData, *this, m_aMutex, aVector) );
 }
 
 } // namespace writer
diff --git a/connectivity/source/inc/ado/ACatalog.hxx b/connectivity/source/inc/ado/ACatalog.hxx
index b3a794800d55..fd34c32d9936 100644
--- a/connectivity/source/inc/ado/ACatalog.hxx
+++ b/connectivity/source/inc/ado/ACatalog.hxx
@@ -44,7 +44,7 @@ namespace connectivity
             ~OCatalog() override;
 
             OConnection*        getConnection()     const { return m_pConnection;   }
-            sdbcx::OCollection* getPrivateTables()  const { return m_pTables;       }
+            sdbcx::OCollection* getPrivateTables()  const { return m_pTables.get(); }
             WpADOCatalog        getCatalog()        const { return m_aCatalog;      }
         };
     }
diff --git a/connectivity/source/inc/hsqldb/HCatalog.hxx b/connectivity/source/inc/hsqldb/HCatalog.hxx
index 5820f2b82de1..f953c9f30ae1 100644
--- a/connectivity/source/inc/hsqldb/HCatalog.hxx
+++ b/connectivity/source/inc/hsqldb/HCatalog.hxx
@@ -49,8 +49,8 @@ namespace connectivity
         public:
             OHCatalog(const css::uno::Reference< css::sdbc::XConnection >& _xConnection);
 
-            sdbcx::OCollection*      getPrivateTables()  const { return m_pTables;}
-            sdbcx::OCollection*      getPrivateViews()   const { return m_pViews; }
+            sdbcx::OCollection*      getPrivateTables()  const { return m_pTables.get(); }
+            sdbcx::OCollection*      getPrivateViews()   const { return m_pViews.get(); }
             const css::uno::Reference< css::sdbc::XConnection >& getConnection() const { return m_xConnection; }
 
             virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
diff --git a/connectivity/source/inc/mysql/YCatalog.hxx b/connectivity/source/inc/mysql/YCatalog.hxx
index 010794968f59..d6b465ff8c84 100644
--- a/connectivity/source/inc/mysql/YCatalog.hxx
+++ b/connectivity/source/inc/mysql/YCatalog.hxx
@@ -49,8 +49,8 @@ namespace connectivity
         public:
             OMySQLCatalog(const css::uno::Reference< css::sdbc::XConnection >& _xConnection);
 
-            sdbcx::OCollection*      getPrivateTables()  const { return m_pTables;}
-            sdbcx::OCollection*      getPrivateViews()   const { return m_pViews; }
+            sdbcx::OCollection*      getPrivateTables()  const { return m_pTables.get();}
+            sdbcx::OCollection*      getPrivateViews()   const { return m_pViews.get(); }
             const css::uno::Reference< css::sdbc::XConnection >& getConnection() const { return m_xConnection; }
 
             virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
diff --git a/connectivity/source/sdbcx/VCatalog.cxx b/connectivity/source/sdbcx/VCatalog.cxx
index 193d18613f66..50d65c2a56c6 100644
--- a/connectivity/source/sdbcx/VCatalog.cxx
+++ b/connectivity/source/sdbcx/VCatalog.cxx
@@ -55,10 +55,6 @@ OCatalog::OCatalog(const Reference< XConnection> &_xConnection) : OCatalog_BASE(
 
 OCatalog::~OCatalog()
 {
-    delete m_pTables;
-    delete m_pViews;
-    delete m_pGroups;
-    delete m_pUsers;
 }
 
 void SAL_CALL OCatalog::release() throw()
@@ -105,7 +101,7 @@ Reference< XNameAccess > SAL_CALL OCatalog::getTables(  )
         // allowed
     }
 
-    return m_pTables;
+    return m_pTables.get();
 }
 
 // XViewsSupplier
@@ -129,7 +125,7 @@ Reference< XNameAccess > SAL_CALL OCatalog::getViews(  )
         // allowed
     }
 
-    return m_pViews;
+    return m_pViews.get();
 }
 
 // XUsersSupplier
@@ -153,7 +149,7 @@ Reference< XNameAccess > SAL_CALL OCatalog::getUsers(  )
         // allowed
     }
 
-    return m_pUsers;
+    return m_pUsers.get();
 }
 
 // XGroupsSupplier
@@ -177,7 +173,7 @@ Reference< XNameAccess > SAL_CALL OCatalog::getGroups(  )
         // allowed
     }
 
-    return m_pGroups;
+    return m_pGroups.get();
 }
 
 OUString OCatalog::buildName(const Reference< XRow >& _xRow)
diff --git a/include/connectivity/sdbcx/VCatalog.hxx b/include/connectivity/sdbcx/VCatalog.hxx
index 0b6ebc463e8e..a5e1dfbb2b1b 100644
--- a/include/connectivity/sdbcx/VCatalog.hxx
+++ b/include/connectivity/sdbcx/VCatalog.hxx
@@ -33,6 +33,7 @@
 #include <connectivity/OSubComponent.hxx>
 #include <connectivity/sdbcx/IRefreshable.hxx>
 #include <connectivity/dbtoolsdllapi.hxx>
+#include <memory>
 
 namespace connectivity
 {
@@ -64,10 +65,10 @@ namespace connectivity
 
             // this members are deleted when the dtor is called
             // they are hold weak
-            OCollection*        m_pTables;
-            OCollection*        m_pViews;
-            OCollection*        m_pGroups;
-            OCollection*        m_pUsers;
+            std::unique_ptr<OCollection> m_pTables;
+            std::unique_ptr<OCollection> m_pViews;
+            std::unique_ptr<OCollection> m_pGroups;
+            std::unique_ptr<OCollection> m_pUsers;
 
             css::uno::Reference< css::sdbc::XDatabaseMetaData > m_xMetaData; // just to make things easier
 


More information about the Libreoffice-commits mailing list