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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Dec 4 06:13:43 UTC 2018


 sw/source/uibase/inc/conttree.hxx    |    2 +-
 sw/source/uibase/uiview/viewsrch.cxx |   10 +++++-----
 sw/source/uibase/utlui/glbltree.cxx  |   17 ++++++-----------
 3 files changed, 12 insertions(+), 17 deletions(-)

New commits:
commit 21c86b6aaa73a4607eefd5e34bb726f16b505f1f
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Dec 3 16:40:32 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Dec 4 07:13:31 2018 +0100

    use unique_ptr in SwView::FUNC_Search
    
    which also fixes a leak
    
    Change-Id: I49da3f4ca3570b9fac44cee4c88c710472ca689e
    Reviewed-on: https://gerrit.libreoffice.org/64471
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx
index 09fd18015ae6..0d645ab7dd00 100644
--- a/sw/source/uibase/uiview/viewsrch.cxx
+++ b/sw/source/uibase/uiview/viewsrch.cxx
@@ -812,18 +812,18 @@ sal_uLong SwView::FUNC_Search( const SwSearchOptions& rOptions )
         ::SfxToSwPageDescAttr( *m_pWrtShell, aSrchSet );
     }
 
-    SfxItemSet* pReplSet = nullptr;
+    std::unique_ptr<SfxItemSet> pReplSet;
     if( bDoReplace && m_pReplList && m_pReplList->Count() )
     {
-        pReplSet = new SfxItemSet( m_pWrtShell->GetAttrPool(),
-                                        aSearchAttrRange );
+        pReplSet.reset( new SfxItemSet( m_pWrtShell->GetAttrPool(),
+                                        aSearchAttrRange ) );
         m_pReplList->Get( *pReplSet );
 
         // -- Page break with page template
         ::SfxToSwPageDescAttr( *m_pWrtShell, *pReplSet );
 
         if( !pReplSet->Count() )        // too bad, we don't know
-            DELETEZ( pReplSet );        // the attributes
+            pReplSet.reset();        // the attributes
     }
 
     // build SearchOptions to be used
@@ -843,7 +843,7 @@ sal_uLong SwView::FUNC_Search( const SwSearchOptions& rOptions )
             rOptions.eEnd,
             eRanges,
             !m_pSrchItem->GetSearchString().isEmpty() ? &aSearchOpt : nullptr,
-            pReplSet );
+            pReplSet.get() );
     }
     else if( m_pSrchItem->GetPattern() )
     {
commit b2f1bd73f96724031edcf78320c51747a339b5e2
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Dec 3 15:44:49 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Dec 4 07:13:20 2018 +0100

    convert m_pDocContent in SwGlobalTree to unique_ptr
    
    Change-Id: I779baa6dcad33aa5fbe49b5143b2b390a747036a
    Reviewed-on: https://gerrit.libreoffice.org/64470
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx
index 98ce484e830d..2d8354607dca 100644
--- a/sw/source/uibase/inc/conttree.hxx
+++ b/sw/source/uibase/inc/conttree.hxx
@@ -267,7 +267,7 @@ private:
     SvTreeListEntry*        m_pDDSource;      // source for Drag'n Drop
     std::unique_ptr<SwGlblDocContents> m_pSwGlblDocContents; // array with sorted content
 
-    SwGlblDocContent*       m_pDocContent;
+    std::unique_ptr<SwGlblDocContent>       m_pDocContent;
     std::unique_ptr<sfx2::DocumentInserter> m_pDocInserter;
 
     bool                m_bIsInternalDrag     :1;
diff --git a/sw/source/uibase/utlui/glbltree.cxx b/sw/source/uibase/utlui/glbltree.cxx
index 5593709267ca..275f71578aae 100644
--- a/sw/source/uibase/utlui/glbltree.cxx
+++ b/sw/source/uibase/utlui/glbltree.cxx
@@ -174,7 +174,6 @@ SwGlobalTree::SwGlobalTree(vcl::Window* pParent, SwNavigationPI* pDialog)
     , m_pActiveShell(nullptr)
     , m_pEmphasisEntry(nullptr)
     , m_pDDSource(nullptr)
-    , m_pDocContent(nullptr)
     , m_bIsInternalDrag(false)
     , m_bLastEntryEmphasis(false)
 {
@@ -796,12 +795,11 @@ void    SwGlobalTree::ExecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry )
     // If a RequestHelp is called during the dialogue,
     // then the content gets lost. Because of that a copy
     // is created in which only the DocPos is set correctly.
-    SwGlblDocContent* pContCopy = nullptr;
+    std::unique_ptr<SwGlblDocContent> pContCopy;
     if(pCont)
-        pContCopy = new SwGlblDocContent(pCont->GetDocPos());
+        pContCopy.reset(new SwGlblDocContent(pCont->GetDocPos()));
     SfxDispatcher& rDispatch = *m_pActiveShell->GetView().GetViewFrame()->GetDispatcher();
     sal_uInt16 nSlot = 0;
-    bool bDeleteContentCopy = true;
     switch( nSelectedPopupEntry )
     {
         case CTX_UPDATE_SEL:
@@ -925,9 +923,8 @@ void    SwGlobalTree::ExecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry )
         break;
         case CTX_INSERT_FILE:
         {
-            bDeleteContentCopy = false;
-            m_pDocContent = pContCopy;
-            InsertRegion( pContCopy );
+            m_pDocContent = std::move(pContCopy);
+            InsertRegion( m_pDocContent.get() );
             pCont = nullptr;
         }
         break;
@@ -1016,8 +1013,6 @@ void    SwGlobalTree::ExecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry )
         rDispatch.Execute(nSlot);
     if(Update( false ))
         Display();
-    if ( bDeleteContentCopy )
-        delete pContCopy;
 }
 
 IMPL_LINK_NOARG(SwGlobalTree, Timeout, Timer *, void)
@@ -1376,8 +1371,8 @@ IMPL_LINK( SwGlobalTree, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg, vo
             pFileNames[nPos++] = sFileName;
         }
         pMedList.reset();
-        InsertRegion( m_pDocContent, aFileNames );
-        DELETEZ( m_pDocContent );
+        InsertRegion( m_pDocContent.get(), aFileNames );
+        m_pDocContent.reset();
     }
 }
 


More information about the Libreoffice-commits mailing list