[Libreoffice-commits] core.git: 2 commits - dbaccess/source mysqlc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Aug 15 06:39:11 UTC 2018


 dbaccess/source/ui/dlg/dbadmin.cxx             |   14 ++++----------
 dbaccess/source/ui/inc/dbadmin.hxx             |    4 ++--
 dbaccess/source/ui/inc/unoadmin.hxx            |    2 +-
 dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx |    2 +-
 dbaccess/source/ui/uno/DBTypeWizDlg.cxx        |    2 +-
 dbaccess/source/ui/uno/DBTypeWizDlgSetup.cxx   |    2 +-
 dbaccess/source/ui/uno/TableFilterDlg.cxx      |    2 +-
 dbaccess/source/ui/uno/UserSettingsDlg.cxx     |    2 +-
 dbaccess/source/ui/uno/admindlg.cxx            |    2 +-
 dbaccess/source/ui/uno/unoadmin.cxx            |    1 -
 mysqlc/source/mysqlc_prepared_resultset.cxx    |   17 +++++++----------
 mysqlc/source/mysqlc_prepared_resultset.hxx    |    6 +++---
 12 files changed, 23 insertions(+), 33 deletions(-)

New commits:
commit 48baa68e3ac12bbaf0d5b7912a0197accf341b25
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Aug 13 14:20:55 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Aug 15 08:38:59 2018 +0200

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

diff --git a/mysqlc/source/mysqlc_prepared_resultset.cxx b/mysqlc/source/mysqlc_prepared_resultset.cxx
index d66259d0a9db..1d5b9ad359bf 100644
--- a/mysqlc/source/mysqlc_prepared_resultset.cxx
+++ b/mysqlc/source/mysqlc_prepared_resultset.cxx
@@ -84,7 +84,7 @@ OPreparedResultSet::OPreparedResultSet(OConnection& rConn, OPreparedStatement* p
 {
     m_nFieldCount = mysql_stmt_field_count(pStmt);
     m_pResult = mysql_stmt_result_metadata(m_pStmt);
-    m_aFields = mysql_fetch_fields(m_pResult);
+    m_aFields.reset(mysql_fetch_fields(m_pResult));
 }
 
 OPreparedResultSet::~OPreparedResultSet() {}
@@ -505,11 +505,8 @@ void SAL_CALL OPreparedResultSet::close()
     MutexGuard aGuard(m_aMutex);
     checkDisposed(OPreparedResultSet_BASE::rBHelper.bDisposed);
 
-    if (m_aData)
-    {
-        delete[] m_aData;
-        delete[] m_aMetaData;
-    }
+    m_aData.reset();
+    m_aMetaData.reset();
 
     if (m_pResult)
         mysql_free_result(m_pResult);
@@ -636,9 +633,9 @@ sal_Bool SAL_CALL OPreparedResultSet::next()
     if (m_aData == nullptr)
     {
         bFirstRun = true;
-        m_aData = new MYSQL_BIND[m_nFieldCount];
-        memset(m_aData, 0, m_nFieldCount * sizeof(MYSQL_BIND));
-        m_aMetaData = new BindMetaData[m_nFieldCount];
+        m_aData.reset(new MYSQL_BIND[m_nFieldCount]);
+        memset(m_aData.get(), 0, m_nFieldCount * sizeof(MYSQL_BIND));
+        m_aMetaData.reset(new BindMetaData[m_nFieldCount]);
     }
     for (sal_Int32 i = 0; i < m_nFieldCount; ++i)
     {
@@ -657,7 +654,7 @@ sal_Bool SAL_CALL OPreparedResultSet::next()
         mysqlc_sdbc_driver::allocateSqlVar(&m_aData[i].buffer, m_aData[i].buffer_type,
                                            m_aFields[i].length);
     }
-    mysql_stmt_bind_result(m_pStmt, m_aData);
+    mysql_stmt_bind_result(m_pStmt, m_aData.get());
     if (bFirstRun)
         mysql_stmt_store_result(m_pStmt);
     int failure = mysql_stmt_fetch(m_pStmt);
diff --git a/mysqlc/source/mysqlc_prepared_resultset.hxx b/mysqlc/source/mysqlc_prepared_resultset.hxx
index db3e1034cb76..53a1b0af10a9 100644
--- a/mysqlc/source/mysqlc_prepared_resultset.hxx
+++ b/mysqlc/source/mysqlc_prepared_resultset.hxx
@@ -70,9 +70,9 @@ class OPreparedResultSet final : public OBase_Mutex,
 
     // Use c style arrays, because we have to work with pointers
     // on these.
-    MYSQL_BIND* m_aData = nullptr;
-    MYSQL_FIELD* m_aFields = nullptr;
-    BindMetaData* m_aMetaData = nullptr;
+    std::unique_ptr<MYSQL_BIND[]> m_aData;
+    std::unique_ptr<MYSQL_FIELD[]> m_aFields;
+    std::unique_ptr<BindMetaData[]> m_aMetaData;
 
     bool m_bWasNull = false;
 
commit 2088dac08b729805e981465526be3aad090462f0
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Sat Aug 11 14:09:12 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Aug 15 08:38:44 2018 +0200

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

diff --git a/dbaccess/source/ui/dlg/dbadmin.cxx b/dbaccess/source/ui/dlg/dbadmin.cxx
index 3cfdc343d6ef..5075f47c4a37 100644
--- a/dbaccess/source/ui/dlg/dbadmin.cxx
+++ b/dbaccess/source/ui/dlg/dbadmin.cxx
@@ -286,7 +286,7 @@ void ODbAdminDialog::clearPassword()
     m_pImpl->clearPassword();
 }
 
-SfxItemSet* ODbAdminDialog::createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults, ::dbaccess::ODsnTypeCollection* _pTypeCollection)
+void ODbAdminDialog::createItemSet(std::unique_ptr<SfxItemSet>& _rpSet, SfxItemPool*& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults, ::dbaccess::ODsnTypeCollection* _pTypeCollection)
 {
     // just to be sure ....
     _rpSet = nullptr;
@@ -431,19 +431,13 @@ SfxItemSet* ODbAdminDialog::createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rp
     _rpPool->FreezeIdRanges();
 
     // and, finally, the set
-    _rpSet = new SfxItemSet(*_rpPool);
-
-    return _rpSet;
+    _rpSet.reset(new SfxItemSet(*_rpPool));
 }
 
-void ODbAdminDialog::destroyItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults)
+void ODbAdminDialog::destroyItemSet(std::unique_ptr<SfxItemSet>& _rpSet, SfxItemPool*& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults)
 {
     // _first_ delete the set (referring the pool)
-    if (_rpSet)
-    {
-        delete _rpSet;
-        _rpSet = nullptr;
-    }
+    _rpSet.reset();
 
     // delete the pool
     if (_rpPool)
diff --git a/dbaccess/source/ui/inc/dbadmin.hxx b/dbaccess/source/ui/inc/dbadmin.hxx
index 2bad2aaaba57..65ff82a197fb 100644
--- a/dbaccess/source/ui/inc/dbadmin.hxx
+++ b/dbaccess/source/ui/inc/dbadmin.hxx
@@ -69,10 +69,10 @@ public:
         @param      _pTypeCollection        pointer to an <type>ODatasourceMap</type>. May be NULL, in this case
                                             the pool will not contain a typecollection default.
     */
-    static SfxItemSet*  createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults, ::dbaccess::ODsnTypeCollection* _pTypeCollection);
+    static void createItemSet(std::unique_ptr<SfxItemSet>& _rpSet, SfxItemPool*& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults, ::dbaccess::ODsnTypeCollection* _pTypeCollection);
     /** destroy and item set / item pool / pool defaults previously created by <method>createItemSet</method>
     */
-    static void         destroyItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults);
+    static void destroyItemSet(std::unique_ptr<SfxItemSet>& _rpSet, SfxItemPool*& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults);
 
     /** selects the DataSource
         @param  _rName
diff --git a/dbaccess/source/ui/inc/unoadmin.hxx b/dbaccess/source/ui/inc/unoadmin.hxx
index 9cd0163046db..8f9013d4d27b 100644
--- a/dbaccess/source/ui/inc/unoadmin.hxx
+++ b/dbaccess/source/ui/inc/unoadmin.hxx
@@ -37,7 +37,7 @@ class ODatabaseAdministrationDialog
         :public ODatabaseAdministrationDialogBase
 {
 protected:
-    SfxItemSet*             m_pDatasourceItems;     // item set for the dialog
+    std::unique_ptr<SfxItemSet> m_pDatasourceItems; // item set for the dialog
     SfxItemPool*            m_pItemPool;            // item pool for the item set for the dialog
     std::vector<SfxPoolItem*>*
                             m_pItemPoolDefaults;    // pool defaults
diff --git a/dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx b/dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx
index 4b361e5ef3e6..9166f0a5c10c 100644
--- a/dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx
+++ b/dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx
@@ -124,7 +124,7 @@ namespace dbaui
 
     svt::OGenericUnoDialog::Dialog OAdvancedSettingsDialog::createDialog(vcl::Window* _pParent)
     {
-        return svt::OGenericUnoDialog::Dialog(VclPtr<AdvancedSettingsDialog>::Create(_pParent, m_pDatasourceItems, m_aContext, m_aInitialSelection));
+        return svt::OGenericUnoDialog::Dialog(VclPtr<AdvancedSettingsDialog>::Create(_pParent, m_pDatasourceItems.get(), m_aContext, m_aInitialSelection));
     }
 
 }   // namespace dbaui
diff --git a/dbaccess/source/ui/uno/DBTypeWizDlg.cxx b/dbaccess/source/ui/uno/DBTypeWizDlg.cxx
index e9f007905ff9..51c075f9d263 100644
--- a/dbaccess/source/ui/uno/DBTypeWizDlg.cxx
+++ b/dbaccess/source/ui/uno/DBTypeWizDlg.cxx
@@ -93,7 +93,7 @@ Reference<XPropertySetInfo>  SAL_CALL ODBTypeWizDialog::getPropertySetInfo()
 
 svt::OGenericUnoDialog::Dialog ODBTypeWizDialog::createDialog(vcl::Window* _pParent)
 {
-    return svt::OGenericUnoDialog::Dialog(VclPtr<ODbTypeWizDialog>::Create(_pParent, m_pDatasourceItems, m_aContext, m_aInitialSelection));
+    return svt::OGenericUnoDialog::Dialog(VclPtr<ODbTypeWizDialog>::Create(_pParent, m_pDatasourceItems.get(), m_aContext, m_aInitialSelection));
 }
 
 }   // namespace dbaui
diff --git a/dbaccess/source/ui/uno/DBTypeWizDlgSetup.cxx b/dbaccess/source/ui/uno/DBTypeWizDlgSetup.cxx
index 645736285d8e..6f7cb96026ea 100644
--- a/dbaccess/source/ui/uno/DBTypeWizDlgSetup.cxx
+++ b/dbaccess/source/ui/uno/DBTypeWizDlgSetup.cxx
@@ -106,7 +106,7 @@ Reference<XPropertySetInfo>  SAL_CALL ODBTypeWizDialogSetup::getPropertySetInfo(
 
 svt::OGenericUnoDialog::Dialog ODBTypeWizDialogSetup::createDialog(vcl::Window* _pParent)
 {
-    return svt::OGenericUnoDialog::Dialog(VclPtr<ODbTypeWizDialogSetup>::Create(_pParent, m_pDatasourceItems, m_aContext, m_aInitialSelection));
+    return svt::OGenericUnoDialog::Dialog(VclPtr<ODbTypeWizDialogSetup>::Create(_pParent, m_pDatasourceItems.get(), m_aContext, m_aInitialSelection));
 }
 
 void ODBTypeWizDialogSetup::executedDialog(sal_Int16 _nExecutionResult)
diff --git a/dbaccess/source/ui/uno/TableFilterDlg.cxx b/dbaccess/source/ui/uno/TableFilterDlg.cxx
index 4a6ef4cf6c3c..b749e9cb573c 100644
--- a/dbaccess/source/ui/uno/TableFilterDlg.cxx
+++ b/dbaccess/source/ui/uno/TableFilterDlg.cxx
@@ -93,7 +93,7 @@ Reference<XPropertySetInfo>  SAL_CALL OTableFilterDialog::getPropertySetInfo()
 
 svt::OGenericUnoDialog::Dialog OTableFilterDialog::createDialog(vcl::Window* _pParent)
 {
-    return svt::OGenericUnoDialog::Dialog(VclPtr<OTableSubscriptionDialog>::Create(_pParent, m_pDatasourceItems, m_aContext, m_aInitialSelection));
+    return svt::OGenericUnoDialog::Dialog(VclPtr<OTableSubscriptionDialog>::Create(_pParent, m_pDatasourceItems.get(), m_aContext, m_aInitialSelection));
 }
 
 }   // namespace dbaui
diff --git a/dbaccess/source/ui/uno/UserSettingsDlg.cxx b/dbaccess/source/ui/uno/UserSettingsDlg.cxx
index f2aa0681e68b..9dac195f4bd4 100644
--- a/dbaccess/source/ui/uno/UserSettingsDlg.cxx
+++ b/dbaccess/source/ui/uno/UserSettingsDlg.cxx
@@ -93,7 +93,7 @@ Reference<XPropertySetInfo>  SAL_CALL OUserSettingsDialog::getPropertySetInfo()
 
 svt::OGenericUnoDialog::Dialog OUserSettingsDialog::createDialog(vcl::Window* _pParent)
 {
-    return svt::OGenericUnoDialog::Dialog(VclPtr<OUserAdminDlg>::Create(_pParent, m_pDatasourceItems, m_aContext, m_aInitialSelection, m_xActiveConnection));
+    return svt::OGenericUnoDialog::Dialog(VclPtr<OUserAdminDlg>::Create(_pParent, m_pDatasourceItems.get(), m_aContext, m_aInitialSelection, m_xActiveConnection));
 }
 
 }   // namespace dbaui
diff --git a/dbaccess/source/ui/uno/admindlg.cxx b/dbaccess/source/ui/uno/admindlg.cxx
index c58afd44919e..a711537e1a4c 100644
--- a/dbaccess/source/ui/uno/admindlg.cxx
+++ b/dbaccess/source/ui/uno/admindlg.cxx
@@ -93,7 +93,7 @@ Reference<XPropertySetInfo>  SAL_CALL ODataSourcePropertyDialog::getPropertySetI
 
 svt::OGenericUnoDialog::Dialog ODataSourcePropertyDialog::createDialog(vcl::Window* _pParent)
 {
-    VclPtrInstance<ODbAdminDialog> pDialog(_pParent, m_pDatasourceItems, m_aContext);
+    VclPtrInstance<ODbAdminDialog> pDialog(_pParent, m_pDatasourceItems.get(), m_aContext);
 
     // the initial selection
     if ( m_aInitialSelection.hasValue() )
diff --git a/dbaccess/source/ui/uno/unoadmin.cxx b/dbaccess/source/ui/uno/unoadmin.cxx
index c19e4d09c9f3..b5039b6e542c 100644
--- a/dbaccess/source/ui/uno/unoadmin.cxx
+++ b/dbaccess/source/ui/uno/unoadmin.cxx
@@ -38,7 +38,6 @@ namespace dbaui
 
 ODatabaseAdministrationDialog::ODatabaseAdministrationDialog(const Reference< XComponentContext >& _rxORB)
     :ODatabaseAdministrationDialogBase(_rxORB)
-    ,m_pDatasourceItems(nullptr)
     ,m_pItemPool(nullptr)
     ,m_pItemPoolDefaults(nullptr)
 {


More information about the Libreoffice-commits mailing list