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

Noel Grandin noel.grandin at collabora.co.uk
Sun Apr 29 15:04:07 UTC 2018


 include/svtools/ctrlbox.hxx        |    2 +-
 include/svtools/ruler.hxx          |    4 ++--
 svtools/source/control/ctrlbox.cxx |    6 ++----
 svtools/source/control/ruler.cxx   |   14 ++++++--------
 4 files changed, 11 insertions(+), 15 deletions(-)

New commits:
commit be2188598ef038f3e110f0a528ae682c93f2a6fd
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Apr 24 13:40:51 2018 +0200

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

diff --git a/include/svtools/ruler.hxx b/include/svtools/ruler.hxx
index 2da312a6b244..bcf4bc27acb3 100644
--- a/include/svtools/ruler.hxx
+++ b/include/svtools/ruler.hxx
@@ -626,9 +626,9 @@ private:
     long            mnStartDragPos;
     long            mnDragPos;
     ImplSVEvent *   mnUpdateEvtId;
-    ImplRulerData*  mpSaveData;
+    std::unique_ptr<ImplRulerData>  mpSaveData;
     ImplRulerData*  mpData;
-    ImplRulerData*  mpDragData;
+    std::unique_ptr<ImplRulerData>  mpDragData;
     tools::Rectangle       maExtraRect;
     WinBits         mnWinStyle;
     sal_uInt16      mnUnitIndex;
diff --git a/svtools/source/control/ruler.cxx b/svtools/source/control/ruler.cxx
index eb34a0204c22..a4d81f1e9adc 100644
--- a/svtools/source/control/ruler.cxx
+++ b/svtools/source/control/ruler.cxx
@@ -181,7 +181,7 @@ void Ruler::ImplInit( WinBits nWinBits )
     mbAutoWinWidth  = true;                 // EditWinWidth == RulerWidth
     mbActive        = true;                 // Is ruler active
     mnUpdateFlags   = 0;                    // What needs to be updated
-    mpData          = mpSaveData;           // Pointer to normal data
+    mpData          = mpSaveData.get();     // Pointer to normal data
     meExtraType     = RulerExtra::DontKnow; // What is in extra field
     meDragType      = RulerType::DontKnow;  // Which element is dragged
 
@@ -257,10 +257,8 @@ void Ruler::dispose()
 {
     if ( mnUpdateEvtId )
         Application::RemoveUserEvent( mnUpdateEvtId );
-    delete mpSaveData;
-    mpSaveData = nullptr;
-    delete mpDragData;
-    mpDragData = nullptr;
+    mpSaveData.reset();
+    mpDragData.reset();
     mxAccContext.clear();
     Window::dispose();
 }
@@ -1758,7 +1756,7 @@ bool Ruler::ImplStartDrag( RulerSelection const * pHitTest, sal_uInt16 nModifier
     mnDragSize      = pHitTest->mnDragSize;
     mnDragModifier  = nModifier;
     *mpDragData     = *mpSaveData;
-    mpData          = mpDragData;
+    mpData          = mpDragData.get();
 
     // call handler
     if (StartDrag())
@@ -1778,7 +1776,7 @@ bool Ruler::ImplStartDrag( RulerSelection const * pHitTest, sal_uInt16 nModifier
         mnDragAryPos    = 0;
         mnDragSize      = RulerDragSize::Move;
         mnDragModifier  = 0;
-        mpData          = mpSaveData;
+        mpData          = mpSaveData.get();
     }
 
     return false;
@@ -1867,7 +1865,7 @@ void Ruler::ImplEndDrag()
     else
         *mpSaveData = *mpDragData;
 
-    mpData = mpSaveData;
+    mpData = mpSaveData.get();
     mbDrag = false;
 
     // call handler
commit 979293ca138ccfb22ff1282b9055ae18b775fed8
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Apr 24 13:42:15 2018 +0200

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

diff --git a/include/svtools/ctrlbox.hxx b/include/svtools/ctrlbox.hxx
index 5e557e24777f..bb080249fa42 100644
--- a/include/svtools/ctrlbox.hxx
+++ b/include/svtools/ctrlbox.hxx
@@ -283,7 +283,7 @@ inline void LineListBox::SetNone( const OUString& sNone )
 class SVT_DLLPUBLIC FontNameBox : public ComboBox
 {
 private:
-    ImplFontList*   mpFontList;
+    std::unique_ptr<ImplFontList> mpFontList;
     bool            mbWYSIWYG;
     OUString        maFontMRUEntriesFile;
 
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index 82cd893e9710..5704f3e9d977 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -669,7 +669,6 @@ void LineListBox::DataChanged( const DataChangedEvent& rDCEvt )
 FontNameBox::FontNameBox( vcl::Window* pParent, WinBits nWinStyle ) :
     ComboBox( pParent, nWinStyle )
 {
-    mpFontList = nullptr;
     mbWYSIWYG = false;
     InitFontMRUEntriesFile();
 }
@@ -759,8 +758,7 @@ void FontNameBox::InitFontMRUEntriesFile()
 
 void FontNameBox::ImplDestroyFontList()
 {
-    delete mpFontList;
-    mpFontList = nullptr;
+    mpFontList.reset();
 }
 
 void FontNameBox::Fill( const FontList* pList )
@@ -772,7 +770,7 @@ void FontNameBox::Fill( const FontList* pList )
     Clear();
 
     ImplDestroyFontList();
-    mpFontList = new ImplFontList;
+    mpFontList.reset(new ImplFontList);
 
     // insert fonts
     sal_uInt16 nFontCount = pList->GetFontNameCount();


More information about the Libreoffice-commits mailing list