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

Noel Grandin noel.grandin at collabora.co.uk
Tue Apr 24 06:21:59 UTC 2018


 include/vcl/edit.hxx          |    6 +++---
 include/vcl/toolbox.hxx       |    7 ++++---
 vcl/source/control/edit.cxx   |   32 +++++++++++---------------------
 vcl/source/window/toolbox.cxx |   10 ++++------
 4 files changed, 22 insertions(+), 33 deletions(-)

New commits:
commit 070980765bc5b2fc3b59e000cdc0611ac1fb622e
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Apr 23 09:44:05 2018 +0200

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

diff --git a/include/vcl/toolbox.hxx b/include/vcl/toolbox.hxx
index 92382df66bce..2018be7986d4 100644
--- a/include/vcl/toolbox.hxx
+++ b/include/vcl/toolbox.hxx
@@ -28,6 +28,7 @@
 #include <o3tl/typed_flags_set.hxx>
 
 #include <limits>
+#include <memory>
 #include <vector>
 
 #include <com/sun/star/frame/XFrame.hpp>
@@ -98,9 +99,9 @@ private:
         ImplToolItems::size_type mnLines;
     };
 
-    ImplToolBoxPrivateData*   mpData;
+    std::unique_ptr<ImplToolBoxPrivateData>   mpData;
     std::vector<ImplToolSize> maFloatSizes;
-    Idle               *mpIdle;
+    std::unique_ptr<Idle>      mpIdle;
     tools::Rectangle           maUpperRect;
     tools::Rectangle           maLowerRect;
     tools::Rectangle           maPaintRect;
@@ -254,7 +255,7 @@ public:
     SAL_DLLPRIVATE void ImplDrawMenuButton(vcl::RenderContext& rRenderContext, bool bHighlight);
     SAL_DLLPRIVATE void ImplDrawButton(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect, sal_uInt16 highlight, bool bChecked, bool bEnabled, bool bIsWindow);
     SAL_DLLPRIVATE ImplToolItems::size_type ImplCountLineBreaks() const;
-    SAL_DLLPRIVATE ImplToolBoxPrivateData* ImplGetToolBoxPrivateData() const { return mpData; }
+    SAL_DLLPRIVATE ImplToolBoxPrivateData* ImplGetToolBoxPrivateData() const { return mpData.get(); }
 
 protected:
     virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 1c92a392e1c2..458c7c6e9566 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -1093,7 +1093,7 @@ void ToolBox::ImplInitToolBoxData()
 {
     // initialize variables
     ImplGetWindowImpl()->mbToolBox  = true;
-    mpData = new ImplToolBoxPrivateData;
+    mpData.reset(new ImplToolBoxPrivateData);
     mpFloatWin        = nullptr;
     mnDX              = 0;
     mnDY              = 0;
@@ -1147,7 +1147,7 @@ void ToolBox::ImplInitToolBoxData()
     mpStatusListener  = new VclStatusListener<ToolBox>(this, ".uno:ImageOrientation");
     mpStatusListener->startListening();
 
-    mpIdle = new Idle("vcl::ToolBox maIdle update");
+    mpIdle.reset(new Idle("vcl::ToolBox maIdle update"));
     mpIdle->SetPriority( TaskPriority::RESIZE );
     mpIdle->SetInvokeHandler( LINK( this, ToolBox, ImplUpdateHdl ) );
 
@@ -1355,8 +1355,7 @@ void ToolBox::dispose()
     mpFloatWin = nullptr;
 
     // delete private data
-    delete mpData;
-    mpData = nullptr;
+    mpData.reset();
 
     ImplSVData* pSVData = ImplGetSVData();
     delete pSVData->maCtrlData.mpTBDragMgr;
@@ -1367,8 +1366,7 @@ void ToolBox::dispose()
 
     mpFloatWin.clear();
 
-    delete mpIdle;
-    mpIdle = nullptr;
+    mpIdle.reset();
 
     DockingWindow::dispose();
 }
commit a11b9c00b84474e1e37fa8abdfd50df87a674cf1
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Apr 23 09:04:04 2018 +0200

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

diff --git a/include/vcl/edit.hxx b/include/vcl/edit.hxx
index a29a0f21ec33..0d353c379f35 100644
--- a/include/vcl/edit.hxx
+++ b/include/vcl/edit.hxx
@@ -71,10 +71,10 @@ class VCL_DLLPUBLIC Edit : public Control, public vcl::unohelper::DragAndDropCli
 {
 private:
     VclPtr<Edit>        mpSubEdit;
-    Timer*              mpUpdateDataTimer;
+    std::unique_ptr<Timer> mpUpdateDataTimer;
     TextFilter*         mpFilterText;
-    DDInfo*             mpDDInfo;
-    Impl_IMEInfos*      mpIMEInfos;
+    std::unique_ptr<DDInfo> mpDDInfo;
+    std::unique_ptr<Impl_IMEInfos> mpIMEInfos;
     OUStringBuffer      maText;
     OUString            maPlaceholderText;
     OUString            maSaveValue;
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index a1671d70bb59..2effdcd3594a 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -227,9 +227,7 @@ Edit::~Edit()
 void Edit::dispose()
 {
     mpUIBuilder.reset();
-
-    delete mpDDInfo;
-    mpDDInfo = nullptr;
+    mpDDInfo.reset();
 
     vcl::Cursor* pCursor = GetCursor();
     if ( pCursor )
@@ -238,11 +236,8 @@ void Edit::dispose()
         delete pCursor;
     }
 
-    delete mpIMEInfos;
-    mpIMEInfos = nullptr;
-
-    delete mpUpdateDataTimer;
-    mpUpdateDataTimer = nullptr;
+    mpIMEInfos.reset();
+    mpUpdateDataTimer.reset();
 
     if ( mxDnDListener.is() )
     {
@@ -2039,16 +2034,14 @@ void Edit::Command( const CommandEvent& rCEvt )
     else if ( rCEvt.GetCommand() == CommandEventId::StartExtTextInput )
     {
         DeleteSelected();
-        delete mpIMEInfos;
         sal_Int32 nPos = static_cast<sal_Int32>(maSelection.Max());
-        mpIMEInfos = new Impl_IMEInfos( nPos, OUString(maText.getStr() + nPos ) );
+        mpIMEInfos.reset(new Impl_IMEInfos( nPos, OUString(maText.getStr() + nPos ) ));
         mpIMEInfos->bWasCursorOverwrite = !IsInsertMode();
     }
     else if ( rCEvt.GetCommand() == CommandEventId::EndExtTextInput )
     {
         bool bInsertMode = !mpIMEInfos->bWasCursorOverwrite;
-        delete mpIMEInfos;
-        mpIMEInfos = nullptr;
+        mpIMEInfos.reset();
 
         SetInsertMode(bInsertMode);
         ImplModified();
@@ -2390,7 +2383,7 @@ void Edit::EnableUpdateData( sal_uLong nTimeout )
     {
         if ( !mpUpdateDataTimer )
         {
-            mpUpdateDataTimer = new Timer("UpdateDataTimer");
+            mpUpdateDataTimer.reset(new Timer("UpdateDataTimer"));
             mpUpdateDataTimer->SetInvokeHandler( LINK( this, Edit, ImplUpdateDataHdl ) );
             mpUpdateDataTimer->SetDebugName( "vcl::Edit mpUpdateDataTimer" );
         }
@@ -2401,8 +2394,7 @@ void Edit::EnableUpdateData( sal_uLong nTimeout )
 
 void Edit::DisableUpdateData()
 {
-    delete mpUpdateDataTimer;
-    mpUpdateDataTimer = nullptr;
+    mpUpdateDataTimer.reset();
 }
 
 void Edit::SetEchoChar( sal_Unicode c )
@@ -2830,7 +2822,7 @@ void Edit::dragGestureRecognized( const css::datatransfer::dnd::DragGestureEvent
         if ( (nCharPos >= aSel.Min()) && (nCharPos < aSel.Max()) )
         {
             if ( !mpDDInfo )
-                mpDDInfo = new DDInfo;
+                mpDDInfo.reset(new DDInfo);
 
             mpDDInfo->bStarterOfDD = true;
             mpDDInfo->aDndStartSel = aSel;
@@ -2872,8 +2864,7 @@ void Edit::dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent& rDSDE
     }
 
     ImplHideDDCursor();
-    delete mpDDInfo;
-    mpDDInfo = nullptr;
+    mpDDInfo.reset();
 }
 
 // css::datatransfer::dnd::XDropTargetListener
@@ -2916,8 +2907,7 @@ void Edit::drop( const css::datatransfer::dnd::DropTargetDropEvent& rDTDE )
 
         if ( !mpDDInfo->bStarterOfDD )
         {
-            delete mpDDInfo;
-            mpDDInfo = nullptr;
+            mpDDInfo.reset();
         }
     }
 
@@ -2928,7 +2918,7 @@ void Edit::dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent& rD
 {
     if ( !mpDDInfo )
     {
-        mpDDInfo = new DDInfo;
+        mpDDInfo.reset(new DDInfo);
     }
     // search for string data type
     const Sequence< css::datatransfer::DataFlavor >& rFlavors( rDTDE.SupportedDataFlavors );


More information about the Libreoffice-commits mailing list