sw/inc/doc.hxx | 4 ++-- sw/source/core/doc/docnew.cxx | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-)
New commits: commit f311dc973e70ed38767a857cd201ee4a73d45830 Author: Michael Stahl <[email protected]> Date: Tue Feb 13 15:01:02 2018 +0100 sw: convert DELETEZ to unique_ptr in SwDoc Change-Id: Ice9957fefea98a878281f64ab129a452a31f27bb Reviewed-on: https://gerrit.libreoffice.org/49668 Tested-by: Jenkins <[email protected]> Reviewed-by: Michael Stahl <[email protected]> diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 331132911936..440127f743fd 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -307,7 +307,7 @@ class SW_DLLPUBLIC SwDoc final // Hash map to find numrules by name mutable std::unordered_map<OUString, SwNumRule *> maNumRuleMap; - SwPagePreviewPrtData *mpPgPViewPrtData; //< Indenting / spacing for printing of page view. + std::unique_ptr<SwPagePreviewPrtData> m_pPgPViewPrtData; //< Indenting / spacing for printing of page view. SwPaM *mpExtInputRing; IStyleAccess *mpStyleAccess; //< handling of automatic styles @@ -1446,7 +1446,7 @@ public: void ClearDoc(); // Deletes all content! // Query /set data for PagePreview. - const SwPagePreviewPrtData* GetPreviewPrtData() const { return mpPgPViewPrtData; } + const SwPagePreviewPrtData* GetPreviewPrtData() const { return m_pPgPViewPrtData.get(); } // If pointer == 0 destroy pointer in document. // Else copy object. diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 5c55de44eb9a..7baf06eb7da1 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -252,7 +252,6 @@ SwDoc::SwDoc() mpURLStateChgd( nullptr ), mpNumberFormatter( nullptr ), mpNumRuleTable( new SwNumRuleTable ), - mpPgPViewPrtData( nullptr ), mpExtInputRing( nullptr ), mpStyleAccess( nullptr ), mpLayoutCache( nullptr ), @@ -406,7 +405,7 @@ SwDoc::~SwDoc() ClrContourCache(); } - delete mpPgPViewPrtData; + m_pPgPViewPrtData.reset(); mbDtor = true; @@ -752,13 +751,19 @@ void SwDoc::SetPreviewPrtData( const SwPagePreviewPrtData* pNew ) { if( pNew ) { - if( mpPgPViewPrtData ) - *mpPgPViewPrtData = *pNew; + if (m_pPgPViewPrtData) + { + *m_pPgPViewPrtData = *pNew; + } else - mpPgPViewPrtData = new SwPagePreviewPrtData( *pNew ); + { + m_pPgPViewPrtData.reset(new SwPagePreviewPrtData(*pNew)); + } + } + else if (m_pPgPViewPrtData) + { + m_pPgPViewPrtData.reset(); } - else if( mpPgPViewPrtData ) - DELETEZ( mpPgPViewPrtData ); getIDocumentState().SetModified(); } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
