From 90da191bc937eedd2a7fda4ac41fbe6a53356842 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 26 May 2021 10:18:05 +0200 Subject: fix leak in SwInsTableDlg Change-Id: I1d4b4f5098eeec7b0042f3ffd457566ecb3e31de Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116188 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/source/ui/table/instable.cxx | 18 +++++++++--------- sw/source/uibase/inc/instable.hxx | 3 ++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/sw/source/ui/table/instable.cxx b/sw/source/ui/table/instable.cxx index 6ace6f4bc10d..4990f7c08112 100644 --- a/sw/source/ui/table/instable.cxx +++ b/sw/source/ui/table/instable.cxx @@ -130,17 +130,17 @@ void SwInsTableDlg::InitAutoTableFormat() m_xLbFormat->connect_changed(LINK(this, SwInsTableDlg, SelFormatHdl)); - pTableTable = new SwTableAutoFormatTable; - pTableTable->Load(); + m_xTableTable.reset(new SwTableAutoFormatTable); + m_xTableTable->Load(); // Add "- none -" style autoformat table. m_xLbFormat->append_text(SwViewShell::GetShellRes()->aStrNone); // Insert to listbox // Add other styles of autoformat tables. - for (sal_uInt8 i = 0, nCount = static_cast(pTableTable->size()); + for (sal_uInt8 i = 0, nCount = static_cast(m_xTableTable->size()); i < nCount; i++) { - SwTableAutoFormat const& rFormat = (*pTableTable)[ i ]; + SwTableAutoFormat const& rFormat = (*m_xTableTable)[ i ]; m_xLbFormat->append_text(rFormat.GetName()); if (pTAutoFormat && rFormat.GetName() == pTAutoFormat->GetName()) lbIndex = i; @@ -148,7 +148,7 @@ void SwInsTableDlg::InitAutoTableFormat() // Change this min variable if you add autotable manually. minTableIndexInLb = 1; - maxTableIndexInLb = minTableIndexInLb + static_cast(pTableTable->size()); + maxTableIndexInLb = minTableIndexInLb + static_cast(m_xTableTable->size()); lbIndex = 0; m_xLbFormat->select( lbIndex ); tbIndex = lbIndexToTableIndex(lbIndex); @@ -187,7 +187,7 @@ IMPL_LINK_NOARG(SwInsTableDlg, SelFormatHdl, weld::TreeView&, void) // To understand this index mapping, look InitAutoTableFormat function to // see how listbox item is implemented. if( tbIndex < 255 ) - m_aWndPreview.NotifyChange( (*pTableTable)[tbIndex] ); + m_aWndPreview.NotifyChange( (*m_xTableTable)[tbIndex] ); else { SwTableAutoFormat aTmp( SwViewShell::GetShellRes()->aStrNone ); @@ -200,14 +200,14 @@ IMPL_LINK_NOARG(SwInsTableDlg, SelFormatHdl, weld::TreeView&, void) IMPL_LINK_NOARG(SwInsTableDlg, OKHdl, weld::Button&, void) { if( tbIndex < 255 ) - pShell->SetTableStyle((*pTableTable)[tbIndex]); + pShell->SetTableStyle((*m_xTableTable)[tbIndex]); if( tbIndex < 255 ) { if( pTAutoFormat ) - *pTAutoFormat = (*pTableTable)[ tbIndex ]; + *pTAutoFormat = (*m_xTableTable)[ tbIndex ]; else - pTAutoFormat = new SwTableAutoFormat( (*pTableTable)[ tbIndex ] ); + pTAutoFormat = new SwTableAutoFormat( (*m_xTableTable)[ tbIndex ] ); } else { diff --git a/sw/source/uibase/inc/instable.hxx b/sw/source/uibase/inc/instable.hxx index e802503c3fb2..593d3668cd31 100644 --- a/sw/source/uibase/inc/instable.hxx +++ b/sw/source/uibase/inc/instable.hxx @@ -30,13 +30,14 @@ #include #include #include +#include class SwInsTableDlg : public SfxDialogController { TextFilter m_aTextFilter; SwWrtShell* pShell; - SwTableAutoFormatTable* pTableTable; + std::unique_ptr m_xTableTable; SwTableAutoFormat* pTAutoFormat; sal_uInt8 lbIndex; -- cgit