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

Stephan Bergmann sbergman at redhat.com
Wed Dec 16 23:51:21 PST 2015


 sw/source/filter/xml/xmlimp.cxx |    6 ++----
 sw/source/filter/xml/xmlimp.hxx |    6 +++++-
 2 files changed, 7 insertions(+), 5 deletions(-)

New commits:
commit 550d95ae6e67a3a0fdbee27ce92712d203383c3e
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Dec 17 08:49:30 2015 +0100

    Manage m_pSttNdIdx via unique_ptr
    
    ...so it gets deleted upon an exception
    
    Change-Id: I239f916019806eef1b761248fd167f5febf25001

diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index 1277267..9a34e8f 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -398,7 +398,6 @@ SwXMLImport::SwXMLImport(
     const uno::Reference< uno::XComponentContext >& rContext,
     OUString const & implementationName, SvXMLImportFlags nImportFlags)
 :   SvXMLImport( rContext, implementationName, nImportFlags ),
-    m_pSttNdIdx( nullptr ),
     m_pTableItemMapper( nullptr ),
     m_pDocElemTokenMap( nullptr ),
     m_pTableElemTokenMap( nullptr ),
@@ -653,7 +652,7 @@ void SwXMLImport::startDocument()
 
     if( (getImportFlags() & SvXMLImportFlags::CONTENT) && !IsStylesOnlyMode() )
     {
-        m_pSttNdIdx = new SwNodeIndex( pDoc->GetNodes() );
+        m_pSttNdIdx.reset(new SwNodeIndex( pDoc->GetNodes() ));
         if( IsInsertMode() )
         {
             SwPaM *pPaM = pTextCursor->GetPaM();
@@ -861,8 +860,7 @@ void SwXMLImport::endDocument()
 
     GetTextImport()->ResetCursor();
 
-    delete m_pSttNdIdx;
-    m_pSttNdIdx = nullptr;
+    m_pSttNdIdx.reset();;
 
     // SJ: #i49801# -> now permitting repaints
     if ( pDoc )
diff --git a/sw/source/filter/xml/xmlimp.hxx b/sw/source/filter/xml/xmlimp.hxx
index ab6227d..fd8caf4 100644
--- a/sw/source/filter/xml/xmlimp.hxx
+++ b/sw/source/filter/xml/xmlimp.hxx
@@ -20,6 +20,10 @@
 #ifndef INCLUDED_SW_SOURCE_FILTER_XML_XMLIMP_HXX
 #define INCLUDED_SW_SOURCE_FILTER_XML_XMLIMP_HXX
 
+#include <sal/config.h>
+
+#include <memory>
+
 #include <com/sun/star/document/XDocumentProperties.hpp>
 
 #include <sot/storage.hxx>
@@ -49,7 +53,7 @@ namespace SwImport {
 
 class SwXMLImport: public SvXMLImport
 {
-    SwNodeIndex             *m_pSttNdIdx;
+    std::unique_ptr<SwNodeIndex> m_pSttNdIdx;
 
     SvXMLUnitConverter      *m_pTwipUnitConv;
     SvXMLImportItemMapper   *m_pTableItemMapper;// paragraph item import


More information about the Libreoffice-commits mailing list