[Libreoffice-commits] .: Branch 'libreoffice-3-5' - 2 commits - sw/source

Miklos Vajna vmiklos at kemper.freedesktop.org
Thu Mar 1 03:42:17 PST 2012


 sw/source/core/inc/frame.hxx      |    2 ++
 sw/source/core/inc/layfrm.hxx     |    4 +++-
 sw/source/core/inc/rootfrm.hxx    |    2 +-
 sw/source/core/inc/sectfrm.hxx    |    2 +-
 sw/source/core/layout/newfrm.cxx  |    9 ++++++++-
 sw/source/core/layout/sectfrm.cxx |   13 +++++++++----
 sw/source/core/layout/ssfrm.cxx   |   22 +++++++++++++++++++---
 7 files changed, 43 insertions(+), 11 deletions(-)

New commits:
commit 5bfeedfcfd542717f40693524dcb7808f23ab42f
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Feb 27 20:43:27 2012 +0100

    SwSectionFrm: initialised members are happy members
    
    Valgrind complained about uninitialised use in
    SwSectionFrm::_CheckClipping (sectfrm.cxx:1111).
    (cherry picked from commit f430b71c46186b53a6364a60b237c81245f3eabb)
    
    Signed-off-by: Miklos Vajna <vmiklos at suse.cz>

diff --git a/sw/source/core/inc/sectfrm.hxx b/sw/source/core/inc/sectfrm.hxx
index bc16e52..c3beb2e 100644
--- a/sw/source/core/inc/sectfrm.hxx
+++ b/sw/source/core/inc/sectfrm.hxx
@@ -71,7 +71,7 @@ protected:
 public:
     SwSectionFrm( SwSection &, SwFrm* );                 //Inhalt wird nicht erzeugt!
     SwSectionFrm( SwSectionFrm &, sal_Bool bMaster );//_Nur_ zum Erzeugen von Master/Follows
-    ~SwSectionFrm();
+    virtual ~SwSectionFrm();
 
     void Init();
     virtual void  CheckDirection( sal_Bool bVert );
diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx
index 3f2ea28..35d38d1 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -71,10 +71,15 @@ SV_IMPL_PTRARR_SORT( SwDestroyList, SwSectionFrmPtr )
 |*  SwSectionFrm::SwSectionFrm(), ~SwSectionFrm()
 |*
 |*************************************************************************/
-SwSectionFrm::SwSectionFrm( SwSection &rSect, SwFrm* pSib ) :
-    SwLayoutFrm( rSect.GetFmt(), pSib ),
-    SwFlowFrm( (SwFrm&)*this ),
-    pSection( &rSect )
+SwSectionFrm::SwSectionFrm( SwSection &rSect, SwFrm* pSib )
+    : SwLayoutFrm( rSect.GetFmt(), pSib )
+    , SwFlowFrm( static_cast<SwFrm&>(*this) )
+    , pSection( &rSect )
+    , bFtnAtEnd(false)
+    , bEndnAtEnd(false)
+    , bCntntLock(false)
+    , bOwnFtnNum(false)
+    , bFtnLock(false)
 {
     nType = FRMC_SECTION;
 
commit 8e28ba240ae2f958a67c2502546651bd9aed76cd
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Feb 27 20:43:27 2012 +0100

    SwRootFrm::~SwRootFrm: refactor:
    
    Since CWS swlayoutrefactoring the SwRootFrms are destroyed with
    SwDoc::IsInDtor not set.  This can cause at least reads of freed
    SwRootFrm members when executing the dtors of SwRootFrm base class
    SwLayoutFrm calling into SwRootFrm::GetPageAtPos.
    
    Prevent this scenario by:
    - moving the implementation of SwRootFrm base class dtors to new
      methods SwFrm::Destroy and SwLayoutFrm::Destroy
    - calling SwFrm::Destroy and SwLayoutFrm::Destroy explicitly before
      SwRootFrm members are freed
    (cherry picked from commit ebb74441790a9852b1a1532d6e025c324666f6fc)
    
    Signed-off-by: Miklos Vajna <vmiklos at suse.cz>

diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx
index 7e4a389..34fcb4b 100644
--- a/sw/source/core/inc/frame.hxx
+++ b/sw/source/core/inc/frame.hxx
@@ -401,6 +401,8 @@ protected:
     void ColLock()      { bColLocked = sal_True; }
     void ColUnlock()    { bColLocked = sal_False; }
 
+    void Destroy(); // for ~SwRootFrm
+
     // Only used by SwRootFrm Ctor to get 'this' into mpRoot...
     void setRootFrm( SwRootFrm* pRoot ) { mpRoot = pRoot; }
 
diff --git a/sw/source/core/inc/layfrm.hxx b/sw/source/core/inc/layfrm.hxx
index 1144a9d..4c4e4e6 100644
--- a/sw/source/core/inc/layfrm.hxx
+++ b/sw/source/core/inc/layfrm.hxx
@@ -56,6 +56,8 @@ class SwLayoutFrm: public SwFrm
 
     void CopySubtree( const SwLayoutFrm *pDest );
 protected:
+    void Destroy(); // for ~SwRootFrm
+
     virtual void Format( const SwBorderAttrs *pAttrs = 0 );
     virtual void MakeAll();
 
@@ -104,7 +106,7 @@ public:
                                    const sal_Bool bDefaultExpand = sal_True ) const;
 
     SwLayoutFrm( SwFrmFmt*, SwFrm* );
-    ~SwLayoutFrm();
+    virtual ~SwLayoutFrm();
 
     virtual void Paint( SwRect const&,
                         SwPrintData const*const pPrintData = NULL ) const;
diff --git a/sw/source/core/inc/rootfrm.hxx b/sw/source/core/inc/rootfrm.hxx
index 788fc55..7e07fae 100644
--- a/sw/source/core/inc/rootfrm.hxx
+++ b/sw/source/core/inc/rootfrm.hxx
@@ -177,7 +177,7 @@ public:
     static sal_Bool HasSameRect( const SwRect& rRect );
 
     SwRootFrm( SwFrmFmt*, ViewShell* );
-    ~SwRootFrm();
+    virtual ~SwRootFrm();
     void Init(SwFrmFmt*);
 
     ViewShell *GetCurrShell() const { return pCurrShell; }
diff --git a/sw/source/core/layout/newfrm.cxx b/sw/source/core/layout/newfrm.cxx
index 3b6b920..5277d83 100644
--- a/sw/source/core/layout/newfrm.cxx
+++ b/sw/source/core/layout/newfrm.cxx
@@ -629,8 +629,15 @@ SwRootFrm::~SwRootFrm()
         (*pCurrShells)[i]->pRoot = 0;
 
     delete pCurrShells;
+    pCurrShells = 0;
 
-    OSL_ENSURE( 0==nAccessibleShells, "Some accessible shells are left" );
+    // Some accessible shells are left => problems on second SwFrm::Destroy call
+    assert(0 == nAccessibleShells);
+
+    // manually call base classes Destroy because it could call stuff
+    // that accesses members of this
+    SwLayoutFrm::Destroy();
+    SwFrm::Destroy();
 }
 
 /*************************************************************************
diff --git a/sw/source/core/layout/ssfrm.cxx b/sw/source/core/layout/ssfrm.cxx
index d0515ef..cade6c4 100644
--- a/sw/source/core/layout/ssfrm.cxx
+++ b/sw/source/core/layout/ssfrm.cxx
@@ -362,7 +362,7 @@ Point SwFrm::GetFrmAnchorPos( sal_Bool bIgnoreFlysAnchoredAtThisFrame ) const
 |*
 |*************************************************************************/
 
-SwFrm::~SwFrm()
+void SwFrm::Destroy()
 {
     // accessible objects for fly and cell frames have been already disposed
     // by the destructors of the derived classes.
@@ -401,6 +401,15 @@ SwFrm::~SwFrm()
             }
         }
         delete pDrawObjs;
+        pDrawObjs = 0;
+    }
+}
+
+SwFrm::~SwFrm()
+{
+    if (!IsRootFrm()) // ~SwRootFrm already calls Destroy!
+    {
+        Destroy();
     }
 
 #if OSL_DEBUG_LEVEL > 0
@@ -554,8 +563,7 @@ void SwCntntFrm::DelFrms( const SwCntntNode& rNode )
 |*
 |*************************************************************************/
 
-
-SwLayoutFrm::~SwLayoutFrm()
+void SwLayoutFrm::Destroy()
 {
     SwFrm *pFrm = pLower;
 
@@ -637,6 +645,14 @@ SwLayoutFrm::~SwLayoutFrm()
     }
 }
 
+SwLayoutFrm::~SwLayoutFrm()
+{
+    if (!IsRootFrm()) // ~SwRootFrm already calls Destroy!
+    {
+        Destroy();
+    }
+}
+
 /*************************************************************************
 |*
 |*  SwFrm::PaintArea()


More information about the Libreoffice-commits mailing list