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

Caolán McNamara caolanm at redhat.com
Fri Mar 24 14:17:32 UTC 2017


 sw/inc/viewsh.hxx              |   14 +++++++-------
 sw/source/core/view/viewsh.cxx |   16 ++++++++--------
 sw/source/core/view/vnew.cxx   |    9 ++-------
 3 files changed, 17 insertions(+), 22 deletions(-)

New commits:
commit 21844db97300e594c212e4a78336cba282a0ad0b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Mar 24 14:13:55 2017 +0000

    valgrind: fix memory leak
    
    Change-Id: I33ad32f4fa6ca6206e98b38f9170634bce9970de

diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index c6e7b6ed81a4..fd3d28132e7c 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -106,16 +106,16 @@ class SW_DLLPUBLIC SwViewShell : public sw::Ring<SwViewShell>
     // Set SwVisArea in order to enable clean formatting before printing.
     friend void SetSwVisArea( SwViewShell *pSh, const SwRect & );
 
-    BitmapEx* m_pReplaceBmp; ///< replaced display of still loaded images
-    BitmapEx* m_pErrorBmp;   ///< error display of missed images
+    std::unique_ptr<BitmapEx> m_xReplaceBmp; ///< replaced display of still loaded images
+    std::unique_ptr<BitmapEx> m_xErrorBmp;   ///< error display of missed images
 
-    static bool mbLstAct;        // true if EndAction of last Shell
-                                    // i.e. if the EndActions of the other
-                                    // Shells on the document are through.
+    static bool mbLstAct;            // true if EndAction of last Shell
+                                     // i.e. if the EndActions of the other
+                                     // Shells on the document are through.
 
-    Point         maPrtOffst;         // Ofst for Printer,
+    Point         maPrtOffst;        // Ofst for Printer,
                                      // non-printable margin.
-     Size         maBrowseBorder;     // Border for frame documents.
+    Size          maBrowseBorder;    // Border for frame documents.
     SwRect        maInvalidRect;
 
     SfxViewShell *mpSfxViewShell;
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 7a868ce94031..d25ac93e2d3d 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -2491,20 +2491,20 @@ const BitmapEx& SwViewShell::GetReplacementBitmap( bool bIsErrorState )
 {
     if (bIsErrorState)
     {
-        if (!m_pErrorBmp)
-            m_pErrorBmp = new BitmapEx(SW_RES(RID_GRAPHIC_ERRORBMP));
-        return *m_pErrorBmp;
+        if (!m_xErrorBmp)
+            m_xErrorBmp.reset(new BitmapEx(SW_RES(RID_GRAPHIC_ERRORBMP)));
+        return *m_xErrorBmp;
     }
 
-    if (!m_pReplaceBmp)
-        m_pReplaceBmp = new BitmapEx(SW_RES(RID_GRAPHIC_REPLACEBMP));
-    return *m_pReplaceBmp;
+    if (!m_xReplaceBmp)
+        m_xReplaceBmp.reset(new BitmapEx(SW_RES(RID_GRAPHIC_REPLACEBMP)));
+    return *m_xReplaceBmp;
 }
 
 void SwViewShell::DeleteReplacementBitmaps()
 {
-    DELETEZ( m_pErrorBmp );
-    DELETEZ( m_pReplaceBmp );
+    m_xErrorBmp.reset();
+    m_xReplaceBmp.reset();
 }
 
 SwPostItMgr* SwViewShell::GetPostItMgr()
diff --git a/sw/source/core/view/vnew.cxx b/sw/source/core/view/vnew.cxx
index 88d593bafd12..c8755a246d39 100644
--- a/sw/source/core/view/vnew.cxx
+++ b/sw/source/core/view/vnew.cxx
@@ -142,9 +142,7 @@ void SwViewShell::Init( const SwViewOption *pNewOpt )
 SwViewShell::SwViewShell( SwDoc& rDocument, vcl::Window *pWindow,
                         const SwViewOption *pNewOpt, OutputDevice *pOutput,
                         long nFlags )
-    : m_pReplaceBmp(nullptr)
-    , m_pErrorBmp(nullptr)
-    ,
+    :
     maBrowseBorder(),
     mpSfxViewShell( nullptr ),
     mpImp( new SwViewShellImp( this ) ),
@@ -217,10 +215,7 @@ SwViewShell::SwViewShell( SwDoc& rDocument, vcl::Window *pWindow,
 /// CTor for further Shells on a document.
 SwViewShell::SwViewShell( SwViewShell& rShell, vcl::Window *pWindow,
                         OutputDevice * pOutput, long const nFlags)
-    : Ring( &rShell )
-    , m_pReplaceBmp(nullptr)
-    , m_pErrorBmp(nullptr)
-    ,
+    : Ring( &rShell ) ,
     maBrowseBorder( rShell.maBrowseBorder ),
     mpSfxViewShell( nullptr ),
     mpImp( new SwViewShellImp( this ) ),


More information about the Libreoffice-commits mailing list