diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-12-08 17:16:48 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-12-09 20:30:20 +0100 |
commit | 7459a283b3a08397d28861dbe588c9f5826398d4 (patch) | |
tree | 38f2980e1c8f790bde8000d5350e9d79b50af159 /sw/source | |
parent | bb966d78980177121a15678ee7933a1ffc971b69 (diff) |
valgrind: more leaks on loading abi3279-1.html
Change-Id: I88d400cdd142094ece9d829a6f54a57e1b967962
Reviewed-on: https://gerrit.libreoffice.org/46106
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/doc/htmltbl.cxx | 30 | ||||
-rw-r--r-- | sw/source/filter/html/htmltab.cxx | 48 | ||||
-rw-r--r-- | sw/source/filter/writer/wrtswtbl.cxx | 6 |
3 files changed, 35 insertions, 49 deletions
diff --git a/sw/source/core/doc/htmltbl.cxx b/sw/source/core/doc/htmltbl.cxx index 9408d76aa681..7c45dd598f16 100644 --- a/sw/source/core/doc/htmltbl.cxx +++ b/sw/source/core/doc/htmltbl.cxx @@ -78,40 +78,26 @@ public: SwHTMLTableLayoutCnts::SwHTMLTableLayoutCnts( const SwStartNode *pSttNd, SwHTMLTableLayout* pTab, bool bNoBrTag, - SwHTMLTableLayoutCnts* pNxt ) : - pNext( pNxt ), pBox( nullptr ), pTable( pTab ), pStartNode( pSttNd ), + std::shared_ptr<SwHTMLTableLayoutCnts> const& rNxt ) : + xNext( rNxt ), pBox( nullptr ), xTable( pTab ), pStartNode( pSttNd ), nPass1Done( 0 ), nWidthSet( 0 ), bNoBreakTag( bNoBrTag ) {} -SwHTMLTableLayoutCnts::~SwHTMLTableLayoutCnts() -{ - delete pNext; - delete pTable; -} - const SwStartNode *SwHTMLTableLayoutCnts::GetStartNode() const { return pBox ? pBox->GetSttNd() : pStartNode; } -SwHTMLTableLayoutCell::SwHTMLTableLayoutCell( SwHTMLTableLayoutCnts *pCnts, +SwHTMLTableLayoutCell::SwHTMLTableLayoutCell(std::shared_ptr<SwHTMLTableLayoutCnts> const& rCnts, sal_uInt16 nRSpan, sal_uInt16 nCSpan, sal_uInt16 nWidth, bool bPrcWidth, bool bNWrapOpt ) : - pContents( pCnts ), + xContents(rCnts), nRowSpan( nRSpan ), nColSpan( nCSpan ), nWidthOption( nWidth ), bPrcWidthOption( bPrcWidth ), bNoWrapOption( bNWrapOpt ) {} -SwHTMLTableLayoutCell::~SwHTMLTableLayoutCell() -{ - if( nRowSpan==1 && nColSpan==1 ) - { - delete pContents; - } -} - SwHTMLTableLayoutColumn::SwHTMLTableLayoutColumn( sal_uInt16 nWidth, bool bRelWidth, bool bLBorder ) : @@ -471,7 +457,7 @@ void SwHTMLTableLayout::AutoLayoutPass1() for( sal_uInt16 j=0; j<m_nRows; j++ ) { SwHTMLTableLayoutCell *pCell = GetCell(j,i); - SwHTMLTableLayoutCnts *pCnts = pCell->GetContents(); + SwHTMLTableLayoutCnts *pCnts = pCell->GetContents().get(); // We need to examine all rows in order to // get the column that should be calculated next. @@ -589,7 +575,7 @@ void SwHTMLTableLayout::AutoLayoutPass1() nAbsMinTableCell = nAbsMinTableCnts; } pCnts->SetPass1Done( m_nPass1Done ); - pCnts = pCnts->GetNext(); + pCnts = pCnts->GetNext().get(); } // This code previously came after AddBorderWidth @@ -1598,7 +1584,7 @@ void SwHTMLTableLayout::SetWidths( bool bCallPass2, sal_uInt16 nAbsAvail, { SwHTMLTableLayoutCell *pCell = GetCell( i, j ); - SwHTMLTableLayoutCnts* pContents = pCell->GetContents(); + SwHTMLTableLayoutCnts* pContents = pCell->GetContents().get(); while( pContents && !pContents->IsWidthSet(m_nWidthSet) ) { SwTableBox *pBox = pContents->GetTableBox(); @@ -1624,7 +1610,7 @@ void SwHTMLTableLayout::SetWidths( bool bCallPass2, sal_uInt16 nAbsAvail, } pContents->SetWidthSet( m_nWidthSet ); - pContents = pContents->GetNext(); + pContents = pContents->GetNext().get(); } } } diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx index c1303ebfe470..b8518a497f17 100644 --- a/sw/source/filter/html/htmltab.cxx +++ b/sw/source/filter/html/htmltab.cxx @@ -167,7 +167,7 @@ class HTMLTableCnts const SwStartNode *m_pStartNode; // a paragraph HTMLTable *m_pTable; // a table - SwHTMLTableLayoutCnts* m_pLayoutInfo; + std::shared_ptr<SwHTMLTableLayoutCnts> m_xLayoutInfo; bool m_bNoBreak; @@ -196,7 +196,7 @@ public: void SetNoBreak() { m_bNoBreak = true; } - SwHTMLTableLayoutCnts *CreateLayoutInfo(); + const std::shared_ptr<SwHTMLTableLayoutCnts>& CreateLayoutInfo(); }; // Cell of a HTML table @@ -616,8 +616,7 @@ public: void HTMLTableCnts::InitCtor() { m_pNext = nullptr; - m_pLayoutInfo = nullptr; - + m_xLayoutInfo.reset(); m_bNoBreak = false; } @@ -651,23 +650,24 @@ void HTMLTableCnts::Add( HTMLTableCnts* pNewCnts ) inline void HTMLTableCnts::SetTableBox( SwTableBox *pBox ) { - OSL_ENSURE( m_pLayoutInfo, "There is no layout info" ); - if( m_pLayoutInfo ) - m_pLayoutInfo->SetTableBox( pBox ); + OSL_ENSURE(m_xLayoutInfo.get(), "There is no layout info"); + if (m_xLayoutInfo) + m_xLayoutInfo->SetTableBox(pBox); } -SwHTMLTableLayoutCnts *HTMLTableCnts::CreateLayoutInfo() +const std::shared_ptr<SwHTMLTableLayoutCnts>& HTMLTableCnts::CreateLayoutInfo() { - if( !m_pLayoutInfo ) + if (!m_xLayoutInfo) { - SwHTMLTableLayoutCnts *pNextInfo = m_pNext ? m_pNext->CreateLayoutInfo() : nullptr; + std::shared_ptr<SwHTMLTableLayoutCnts> xNextInfo; + if (m_pNext) + xNextInfo = m_pNext->CreateLayoutInfo(); SwHTMLTableLayout *pTableInfo = m_pTable ? m_pTable->CreateLayoutInfo() : nullptr; - m_pLayoutInfo = new SwHTMLTableLayoutCnts( m_pStartNode, pTableInfo, - m_bNoBreak, pNextInfo ); + m_xLayoutInfo.reset(new SwHTMLTableLayoutCnts(m_pStartNode, pTableInfo, m_bNoBreak, xNextInfo)); } - return m_pLayoutInfo; + return m_xLayoutInfo; } HTMLTableCell::HTMLTableCell(): @@ -744,10 +744,11 @@ inline bool HTMLTableCell::GetValue( double& rValue ) const std::unique_ptr<SwHTMLTableLayoutCell> HTMLTableCell::CreateLayoutInfo() { - SwHTMLTableLayoutCnts *pCntInfo = m_xContents ? m_xContents->CreateLayoutInfo() : nullptr; - - return std::unique_ptr<SwHTMLTableLayoutCell>(new SwHTMLTableLayoutCell( pCntInfo, nRowSpan, nColSpan, nWidth, - bRelWidth, bNoWrap )); + std::shared_ptr<SwHTMLTableLayoutCnts> xCntInfo; + if (m_xContents) + xCntInfo = m_xContents->CreateLayoutInfo(); + return std::unique_ptr<SwHTMLTableLayoutCell>(new SwHTMLTableLayoutCell(xCntInfo, nRowSpan, nColSpan, nWidth, + bRelWidth, bNoWrap)); } HTMLTableRow::HTMLTableRow(sal_uInt16 const nCells) @@ -1097,11 +1098,10 @@ SwHTMLTableLayout *HTMLTable::CreateLayoutInfo() if( bExportable ) { - SwHTMLTableLayoutCnts *pLayoutCnts = + const std::shared_ptr<SwHTMLTableLayoutCnts>& rLayoutCnts = pLayoutCell->GetContents(); - bExportable = !pLayoutCnts || - ( pLayoutCnts->GetStartNode() && - !pLayoutCnts->GetNext() ); + bExportable = !rLayoutCnts || + (rLayoutCnts->GetStartNode() && !rLayoutCnts->GetNext()); } } } @@ -1625,12 +1625,12 @@ SwTableLine *HTMLTable::MakeTableLine( SwTableBox *pUpper, GetPrevBoxStartNode( nTopRow, nStartCol ); std::shared_ptr<HTMLTableCnts> xCnts(new HTMLTableCnts( m_pParser->InsertTableSection(pPrevStartNd))); - SwHTMLTableLayoutCnts *pCntsLayoutInfo = + const std::shared_ptr<SwHTMLTableLayoutCnts> xCntsLayoutInfo = xCnts->CreateLayoutInfo(); pCell2->SetContents(xCnts); SwHTMLTableLayoutCell *pCurrCell = m_pLayoutInfo->GetCell( nTopRow, nStartCol ); - pCurrCell->SetContents( pCntsLayoutInfo ); + pCurrCell->SetContents(xCntsLayoutInfo); if( nBoxRowSpan < 0 ) pCurrCell->SetRowSpan( 0 ); @@ -1639,7 +1639,7 @@ SwTableLine *HTMLTable::MakeTableLine( SwTableBox *pUpper, { GetCell(nTopRow,j)->SetContents(xCnts); m_pLayoutInfo->GetCell( nTopRow, j ) - ->SetContents( pCntsLayoutInfo ); + ->SetContents(xCntsLayoutInfo); } } diff --git a/sw/source/filter/writer/wrtswtbl.cxx b/sw/source/filter/writer/wrtswtbl.cxx index b059f04eaa5d..12d26d1b7a53 100644 --- a/sw/source/filter/writer/wrtswtbl.cxx +++ b/sw/source/filter/writer/wrtswtbl.cxx @@ -817,13 +817,13 @@ SwWriteTable::SwWriteTable(const SwTable* pTable, const SwHTMLTableLayout *pLayo pLayoutInfo->GetCell( nRow, nCol ); const SwHTMLTableLayoutCnts *pLayoutCnts = - pLayoutCell->GetContents(); + pLayoutCell->GetContents().get(); // The cell begins actually a row above or further forward? if( ( nRow>0 && pLayoutCnts == pLayoutInfo->GetCell(nRow-1,nCol) - ->GetContents() ) || + ->GetContents().get() ) || ( nCol>0 && pLayoutCnts == pLayoutInfo->GetCell(nRow,nCol-1) - ->GetContents() ) ) + ->GetContents().get() ) ) { continue; } |