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

Michael Stahl mstahl at redhat.com
Tue Feb 20 09:24:17 UTC 2018


 sw/inc/ndtxt.hxx                 |   10 +++++-----
 sw/source/core/txtnode/ndtxt.cxx |   13 ++++---------
 2 files changed, 9 insertions(+), 14 deletions(-)

New commits:
commit 76d5b9d0cf0b0f1f15205b06a26399425e2a345e
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Feb 19 11:28:40 2018 +0100

    sw: convert DELETEZ to unique_ptr in SwTextNode
    
    Change-Id: I0df469be660c20513f82b465412ffcf31b0a0f63
    Reviewed-on: https://gerrit.libreoffice.org/49990
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index 941115235e56..98abc094707b 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -82,7 +82,7 @@ class SW_DLLPUBLIC SwTextNode: public SwContentNode, public ::sfx2::Metadatable
 
     /** May be 0. It is only then not 0 if it contains hard attributes.
        Therefore: never access directly! */
-    SwpHints    *m_pSwpHints;
+    std::unique_ptr<SwpHints> m_pSwpHints;
 
     mutable SwNodeNum* mpNodeNum;  ///< Numbering for this paragraph.
 
@@ -213,8 +213,8 @@ public:
     /// getters for SwpHints
     inline       SwpHints &GetSwpHints();
     inline const SwpHints &GetSwpHints() const;
-    SwpHints *GetpSwpHints()       { return m_pSwpHints; }
-    const SwpHints *GetpSwpHints() const { return m_pSwpHints; }
+          SwpHints *GetpSwpHints()       { return m_pSwpHints.get(); }
+    const SwpHints *GetpSwpHints() const { return m_pSwpHints.get(); }
     bool   HasHints() const { return m_pSwpHints != nullptr; }
     inline       SwpHints &GetOrCreateSwpHints();
 
@@ -810,7 +810,7 @@ inline SwpHints& SwTextNode::GetOrCreateSwpHints()
 {
     if ( !m_pSwpHints )
     {
-        m_pSwpHints = new SwpHints;
+        m_pSwpHints.reset(new SwpHints);
     }
     return *m_pSwpHints;
 }
@@ -819,7 +819,7 @@ inline void SwTextNode::TryDeleteSwpHints()
 {
     if ( m_pSwpHints && m_pSwpHints->CanBeDeleted() )
     {
-        DELETEZ( m_pSwpHints );
+        m_pSwpHints.reset();
     }
 }
 
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index a442be331735..c9c5bbfb579a 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -198,7 +198,6 @@ SwTextNode *SwNodes::MakeTextNode( const SwNodeIndex & rWhere,
 
 SwTextNode::SwTextNode( const SwNodeIndex &rWhere, SwTextFormatColl *pTextColl, const SfxItemSet* pAutoAttr )
 :   SwContentNode( rWhere, SwNodeType::Text, pTextColl ),
-    m_pSwpHints( nullptr ),
     mpNodeNum( nullptr ),
     m_Text(),
     m_pParaIdleData_Impl(nullptr),
@@ -244,8 +243,7 @@ SwTextNode::~SwTextNode()
     if ( m_pSwpHints )
     {
         // do not delete attributes twice when those delete their content
-        SwpHints* pTmpHints = m_pSwpHints;
-        m_pSwpHints = nullptr;
+        std::unique_ptr<SwpHints> pTmpHints(std::move(m_pSwpHints));
 
         for( size_t j = pTmpHints->Count(); j; )
         {
@@ -253,8 +251,6 @@ SwTextNode::~SwTextNode()
             // if would delete itself
             DestroyAttr( pTmpHints->Get( --j ) );
         }
-
-        delete pTmpHints;
     }
 
     // must be removed from outline nodes by now
@@ -445,8 +441,7 @@ SwContentNode *SwTextNode::SplitContentNode( const SwPosition &rPos )
         {
             if ( pNode->m_pSwpHints->CanBeDeleted() )
             {
-                delete pNode->m_pSwpHints;
-                pNode->m_pSwpHints = nullptr;
+                pNode->m_pSwpHints.reset();
             }
             else
             {
@@ -1398,7 +1393,7 @@ SwTextNode::GetTextAttrsAt(sal_Int32 const nIndex, sal_uInt16 const nWhich) cons
 {
     assert(nWhich >= RES_TXTATR_BEGIN && nWhich < RES_TXTATR_END);
     std::vector<SwTextAttr *> ret;
-    lcl_GetTextAttrs(& ret, nullptr, m_pSwpHints, nIndex, nWhich, DEFAULT);
+    lcl_GetTextAttrs(&ret, nullptr, m_pSwpHints.get(), nIndex, nWhich, DEFAULT);
     return ret;
 }
 
@@ -1416,7 +1411,7 @@ SwTextNode::GetTextAttrAt(sal_Int32 const nIndex, sal_uInt16 const nWhich,
             // "GetTextAttrAt() will give wrong result for this hint!")
 
     SwTextAttr * pRet(nullptr);
-    lcl_GetTextAttrs(nullptr, & pRet, m_pSwpHints, nIndex, nWhich, eMode);
+    lcl_GetTextAttrs(nullptr, & pRet, m_pSwpHints.get(), nIndex, nWhich, eMode);
     return pRet;
 }
 


More information about the Libreoffice-commits mailing list