[Libreoffice-commits] core.git: 2 commits - cui/source sw/inc sw/source

Noel Grandin noel.grandin at collabora.co.uk
Mon Jun 25 07:12:11 UTC 2018


 cui/source/tabpages/backgrnd.cxx |    9 +++---
 sw/inc/accmap.hxx                |   12 ++++-----
 sw/source/core/access/accmap.cxx |   52 +++++++++++++++------------------------
 3 files changed, 30 insertions(+), 43 deletions(-)

New commits:
commit 9a378c7af1b0ef368f6381c8496369460fa7974d
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu Jun 21 09:54:36 2018 +0200

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

diff --git a/cui/source/tabpages/backgrnd.cxx b/cui/source/tabpages/backgrnd.cxx
index 76f5a1567207..9d9fa98d1f54 100644
--- a/cui/source/tabpages/backgrnd.cxx
+++ b/cui/source/tabpages/backgrnd.cxx
@@ -161,7 +161,7 @@ private:
     void recalcDrawPos();
 
     bool            bIsBmp;
-    Bitmap*         pBitmap;
+    std::unique_ptr<Bitmap> pBitmap;
     Point           aDrawPos;
     Size            aDrawSize;
     ::tools::Rectangle       aDrawRect;
@@ -195,8 +195,7 @@ BackgroundPreviewImpl::~BackgroundPreviewImpl()
 
 void BackgroundPreviewImpl::dispose()
 {
-    delete pBitmap;
-    pBitmap = nullptr;
+    pBitmap.reset();
     vcl::Window::dispose();
 }
 
@@ -218,9 +217,9 @@ void BackgroundPreviewImpl::NotifyChange( const Bitmap* pNewBitmap )
         if (pNewBitmap && pBitmap)
             *pBitmap = *pNewBitmap;
         else if (pNewBitmap && !pBitmap)
-            pBitmap = new Bitmap(*pNewBitmap);
+            pBitmap.reset( new Bitmap(*pNewBitmap) );
         else if (!pNewBitmap)
-            DELETEZ(pBitmap);
+            pBitmap.reset();
 
         recalcDrawPos();
 
commit 641cb17f5e11cafad0413e2a673fdad2b8c42903
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu Jun 21 09:11:42 2018 +0200

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

diff --git a/sw/inc/accmap.hxx b/sw/inc/accmap.hxx
index c78bea3e0e51..330c4436d613 100644
--- a/sw/inc/accmap.hxx
+++ b/sw/inc/accmap.hxx
@@ -91,14 +91,14 @@ class SwAccessibleMap : public ::accessibility::IAccessibleViewForwarder,
 {
     mutable ::osl::Mutex maMutex;
     ::osl::Mutex maEventMutex;
-    SwAccessibleContextMap_Impl *mpFrameMap;
-    SwAccessibleShapeMap_Impl *mpShapeMap;
+    std::unique_ptr<SwAccessibleContextMap_Impl> mpFrameMap;
+    std::unique_ptr<SwAccessibleShapeMap_Impl> mpShapeMap;
     SwShapeList_Impl mvShapes;
-    SwAccessibleEventList_Impl *mpEvents;
-    SwAccessibleEventMap_Impl *mpEventMap;
+    std::unique_ptr<SwAccessibleEventList_Impl> mpEvents;
+    std::unique_ptr<SwAccessibleEventMap_Impl> mpEventMap;
     // #i27301 data structure to keep information about
     // accessible paragraph, which have a selection.
-    SwAccessibleSelectedParas_Impl* mpSelectedParas;
+    std::unique_ptr<SwAccessibleSelectedParas_Impl> mpSelectedParas;
     SwViewShell *mpVSh;
     /// for page preview: store preview data, VisArea, and mapping of
     /// preview-to-display coordinates
@@ -135,7 +135,7 @@ class SwAccessibleMap : public ::accessibility::IAccessibleViewForwarder,
 
         Important note: method has to used inside a mutual exclusive section
     */
-    SwAccessibleSelectedParas_Impl* BuildSelectedParas();
+    std::unique_ptr<SwAccessibleSelectedParas_Impl> BuildSelectedParas();
 
 public:
 
diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index 3ab340928a27..875ea4f21d5b 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -945,9 +945,9 @@ void SwAccessibleMap::AppendEvent( const SwAccessibleEvent_Impl& rEvent )
     osl::MutexGuard aGuard( maEventMutex );
 
     if( !mpEvents )
-        mpEvents = new SwAccessibleEventList_Impl;
+        mpEvents.reset(new SwAccessibleEventList_Impl);
     if( !mpEventMap )
-        mpEventMap = new SwAccessibleEventMap_Impl;
+        mpEventMap.reset(new SwAccessibleEventMap_Impl);
 
     if( mpEvents->IsFiring() )
     {
@@ -1694,13 +1694,10 @@ SwAccessibleMap::~SwAccessibleMap()
                 "Frame map should be empty after disposing the root frame");
         assert((!mpShapeMap || mpShapeMap->empty()) &&
                 "Object map should be empty after disposing the root frame");
-        delete mpFrameMap;
-        mpFrameMap = nullptr;
-        delete mpShapeMap;
-        mpShapeMap = nullptr;
+        mpFrameMap.reset();
+        mpShapeMap.reset();
         mvShapes.clear();
-        delete mpSelectedParas;
-        mpSelectedParas = nullptr;
+        mpSelectedParas.reset();
     }
 
     mpPreview.reset();
@@ -1709,10 +1706,8 @@ SwAccessibleMap::~SwAccessibleMap()
         osl::MutexGuard aGuard( maEventMutex );
         assert(!mpEvents);
         assert(!mpEventMap);
-        delete mpEventMap;
-        mpEventMap = nullptr;
-        delete mpEvents;
-        mpEvents = nullptr;
+        mpEventMap.reset();
+        mpEvents.reset();
     }
     mpVSh->GetLayout()->RemoveAccessibleShell();
 }
@@ -1728,7 +1723,7 @@ uno::Reference< XAccessible > SwAccessibleMap::GetDocumentView_(
 
         if( !mpFrameMap )
         {
-            mpFrameMap = new SwAccessibleContextMap_Impl;
+            mpFrameMap.reset(new SwAccessibleContextMap_Impl);
 #if OSL_DEBUG_LEVEL > 0
             mpFrameMap->mbLocked = false;
 #endif
@@ -1811,7 +1806,7 @@ uno::Reference< XAccessible> SwAccessibleMap::GetContext( const SwFrame *pFrame,
         osl::MutexGuard aGuard( maMutex );
 
         if( !mpFrameMap && bCreate )
-            mpFrameMap = new SwAccessibleContextMap_Impl;
+            mpFrameMap.reset(new SwAccessibleContextMap_Impl);
         if( mpFrameMap )
         {
             SwAccessibleContextMap_Impl::iterator aIter = mpFrameMap->find( pFrame );
@@ -1951,7 +1946,7 @@ uno::Reference< XAccessible> SwAccessibleMap::GetContext(
         osl::MutexGuard aGuard( maMutex );
 
         if( !mpShapeMap && bCreate )
-            mpShapeMap = new SwAccessibleShapeMap_Impl( this );
+            mpShapeMap.reset(new SwAccessibleShapeMap_Impl( this ));
         if( mpShapeMap )
         {
             SwAccessibleShapeMap_Impl::iterator aIter = mpShapeMap->find( pObj );
@@ -2126,8 +2121,7 @@ void SwAccessibleMap::RemoveContext( const SwFrame *pFrame )
 
             if( mpFrameMap->empty() )
             {
-                delete mpFrameMap;
-                mpFrameMap = nullptr;
+                mpFrameMap.reset();
             }
         }
     }
@@ -2151,8 +2145,7 @@ void SwAccessibleMap::RemoveContext( const SdrObject *pObj )
 
             if( mpShapeMap && mpShapeMap->empty() )
             {
-                delete mpShapeMap;
-                mpShapeMap = nullptr;
+                mpShapeMap.reset();
             }
         }
     }
@@ -3016,11 +3009,8 @@ void SwAccessibleMap::FireEvents()
             for( auto const& aEvent : *mpEvents )
                  FireEvent(aEvent);
 
-            delete mpEventMap;
-            mpEventMap = nullptr;
-
-            delete mpEvents;
-            mpEvents = nullptr;
+            mpEventMap.reset();
+            mpEvents.reset();
         }
     }
     {
@@ -3116,7 +3106,7 @@ bool SwAccessibleMap::ReplaceChild (
         osl::MutexGuard aGuard( maMutex );
 
         if( !mpShapeMap )
-            mpShapeMap = new SwAccessibleShapeMap_Impl( this );
+            mpShapeMap.reset(new SwAccessibleShapeMap_Impl( this ));
 
         // create the new child
         ::accessibility::ShapeTypeHandler& rShapeTypeHandler =
@@ -3272,7 +3262,7 @@ Size SwAccessibleMap::GetPreviewPageSize(sal_uInt16 const nPreviewPageNum) const
     which have a selection
     Important note: method has to be used inside a mutual exclusive section
 */
-SwAccessibleSelectedParas_Impl* SwAccessibleMap::BuildSelectedParas()
+std::unique_ptr<SwAccessibleSelectedParas_Impl> SwAccessibleMap::BuildSelectedParas()
 {
     // no accessible contexts, no selection
     if ( !mpFrameMap )
@@ -3302,7 +3292,7 @@ SwAccessibleSelectedParas_Impl* SwAccessibleMap::BuildSelectedParas()
         return nullptr;
     }
 
-    SwAccessibleSelectedParas_Impl* pRetSelectedParas( nullptr );
+    std::unique_ptr<SwAccessibleSelectedParas_Impl> pRetSelectedParas;
 
     // loop on all cursors
     SwPaM* pRingStart = pCursor;
@@ -3342,8 +3332,8 @@ SwAccessibleSelectedParas_Impl* SwAccessibleMap::BuildSelectedParas()
                                                 : -1 );
                                 if ( !pRetSelectedParas )
                                 {
-                                    pRetSelectedParas =
-                                            new SwAccessibleSelectedParas_Impl;
+                                    pRetSelectedParas.reset(
+                                            new SwAccessibleSelectedParas_Impl);
                                 }
                                 pRetSelectedParas->emplace( xWeakAcc, aDataEntry );
                             }
@@ -3364,7 +3354,7 @@ void SwAccessibleMap::InvalidateTextSelectionOfAllParas()
     osl::MutexGuard aGuard( maMutex );
 
     // keep previously known selected paragraphs
-    SwAccessibleSelectedParas_Impl* pPrevSelectedParas( mpSelectedParas );
+    std::unique_ptr<SwAccessibleSelectedParas_Impl> pPrevSelectedParas( std::move(mpSelectedParas) );
 
     // determine currently selected paragraphs
     mpSelectedParas = BuildSelectedParas();
@@ -3457,8 +3447,6 @@ void SwAccessibleMap::InvalidateTextSelectionOfAllParas()
                 }
             }
         }
-
-        delete pPrevSelectedParas;
     }
 }
 


More information about the Libreoffice-commits mailing list