[Libreoffice-commits] core.git: 2 commits - compilerplugins/clang extensions/source

Noel Grandin noel.grandin at collabora.co.uk
Mon May 28 06:45:42 UTC 2018


 compilerplugins/clang/useuniqueptr.cxx     |    3 +++
 extensions/source/abpilot/abpfinalpage.cxx |    6 +++---
 extensions/source/abpilot/abpfinalpage.hxx |    2 +-
 extensions/source/scanner/grid.cxx         |   12 ++++++------
 4 files changed, 13 insertions(+), 10 deletions(-)

New commits:
commit 0f30c9a1ef185a76c353349f497e576cfce0cd13
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu May 17 14:51:04 2018 +0200

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

diff --git a/compilerplugins/clang/useuniqueptr.cxx b/compilerplugins/clang/useuniqueptr.cxx
index f09701c03ca6..4dc5b85dbf3b 100644
--- a/compilerplugins/clang/useuniqueptr.cxx
+++ b/compilerplugins/clang/useuniqueptr.cxx
@@ -56,6 +56,9 @@ public:
         // can't use std::set<std::unique_ptr<>> until C++14
         if (fn == SRCDIR "/editeng/source/misc/svxacorr.cxx")
             return;
+        // horrible horrible spawn of evil ownership and deletion here
+        if (fn == SRCDIR "/sfx2/source/view/ipclient.cxx")
+            return;
 
         TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
     }
diff --git a/extensions/source/scanner/grid.cxx b/extensions/source/scanner/grid.cxx
index 30a325bd3ac0..b6be058570e9 100644
--- a/extensions/source/scanner/grid.cxx
+++ b/extensions/source/scanner/grid.cxx
@@ -80,7 +80,7 @@ class GridWindow : public vcl::Window
     double*         m_pXValues;
     double*         m_pOrigYValues;
     int             m_nValues;
-    double*         m_pNewYValues;
+    std::unique_ptr<double[]> m_pNewYValues;
 
     sal_uInt16      m_BmOffX;
     sal_uInt16      m_BmOffY;
@@ -128,7 +128,7 @@ public:
 
     void setBoundings( double fMinX, double fMinY, double fMaxX, double fMaxY );
 
-    double* getNewYValues() { return m_pNewYValues; }
+    double* getNewYValues() { return m_pNewYValues.get(); }
 
     void ChangeMode(ResetType nType);
 
@@ -172,8 +172,8 @@ void GridWindow::Init(double* pXValues, double* pYValues, int nValues, bool bCut
 
     if (m_pOrigYValues && m_nValues)
     {
-        m_pNewYValues = new double[ m_nValues ];
-        memcpy( m_pNewYValues, m_pOrigYValues, sizeof( double ) * m_nValues );
+        m_pNewYValues.reset(new double[ m_nValues ]);
+        memcpy( m_pNewYValues.get(), m_pOrigYValues, sizeof( double ) * m_nValues );
     }
 
     setBoundings( 0, 0, 1023, 1023 );
@@ -238,7 +238,7 @@ GridWindow::~GridWindow()
 
 void GridWindow::dispose()
 {
-    delete [] m_pNewYValues;
+    m_pNewYValues.reset();
     vcl::Window::dispose();
 }
 
@@ -657,7 +657,7 @@ void GridWindow::ChangeMode(ResetType nType)
         case ResetType::RESET:
         {
             if( m_pOrigYValues && m_pNewYValues && m_nValues )
-                memcpy( m_pNewYValues, m_pOrigYValues, m_nValues*sizeof(double) );
+                memcpy( m_pNewYValues.get(), m_pOrigYValues, m_nValues*sizeof(double) );
         }
         break;
         case ResetType::EXPONENTIAL:
commit 34652fc397757ddb2cc9f1a3646bed2d031998c1
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu May 17 14:50:37 2018 +0200

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

diff --git a/extensions/source/abpilot/abpfinalpage.cxx b/extensions/source/abpilot/abpfinalpage.cxx
index 73d0cdfe58a6..7bd03896f0c3 100644
--- a/extensions/source/abpilot/abpfinalpage.cxx
+++ b/extensions/source/abpilot/abpfinalpage.cxx
@@ -53,8 +53,8 @@ namespace abp
         get(m_pLocationLabel, "locationft");
         get(m_pName, "name");
         get(m_pDuplicateNameError, "warning");
-        m_pLocationController = new svx::DatabaseLocationInputController(_pParent->getORB(),
-            *m_pLocation, *m_pBrowse);
+        m_pLocationController.reset( new svx::DatabaseLocationInputController(_pParent->getORB(),
+            *m_pLocation, *m_pBrowse) );
 
         m_pName->SetModifyHdl( LINK(this, FinalPage, OnNameModified) );
         m_pLocation->SetModifyHdl( LINK(this, FinalPage, OnNameModified) );
@@ -72,7 +72,7 @@ namespace abp
 
     void FinalPage::dispose()
     {
-        delete m_pLocationController;
+        m_pLocationController.reset();
         m_pLocation.clear();
         m_pBrowse.clear();
         m_pRegisterName.clear();
diff --git a/extensions/source/abpilot/abpfinalpage.hxx b/extensions/source/abpilot/abpfinalpage.hxx
index 0c92487ed29a..595806a77570 100644
--- a/extensions/source/abpilot/abpfinalpage.hxx
+++ b/extensions/source/abpilot/abpfinalpage.hxx
@@ -43,7 +43,7 @@ namespace abp
         VclPtr<Edit>             m_pName;
         VclPtr<FixedText>        m_pDuplicateNameError;
 
-        svx::DatabaseLocationInputController*
+        std::unique_ptr<svx::DatabaseLocationInputController>
                         m_pLocationController;
 
         StringBag       m_aInvalidDataSourceNames;


More information about the Libreoffice-commits mailing list