diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-07-27 20:11:37 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-07-27 21:58:18 +0200 |
commit | 62a803532f0cb8f777037d0915c1e69166963fd2 (patch) | |
tree | 4b6c7769f4409087a56b2bb6f4d46a3093c264f7 | |
parent | weld SwStdFontTabPage (diff) | |
download | core-62a803532f0cb8f777037d0915c1e69166963fd2.tar.gz core-62a803532f0cb8f777037d0915c1e69166963fd2.zip |
dispose printer if we created it
old code for ~this broken by...
commit 40df5fc0e30c0aa32157c645db8b5256dc8afcc3
Author: Caolán McNamara <caolanm@redhat.com>
Date: Tue Jul 9 12:34:12 2013 +0100
mem leaks in writer font options tabpage
some addled thinking there leading to it getting removed with
commit 1bf97d99e7529f1a69688522ac271636059a3391
Date: Sat Jun 25 23:03:53 2016 +0200
loplugin:singlevalfields in sw(part1)
Change-Id: I6d36fa614fb8d4ede41fc5d391f945c949a79409
Reviewed-on: https://gerrit.libreoffice.org/76483
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sw/source/ui/config/optpage.cxx | 13 | ||||
-rw-r--r-- | sw/source/uibase/inc/optpage.hxx | 1 |
2 files changed, 13 insertions, 1 deletions
diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx index 751bc0a638c7..8402c24e0930 100644 --- a/sw/source/ui/config/optpage.cxx +++ b/sw/source/ui/config/optpage.cxx @@ -502,6 +502,7 @@ SwStdFontTabPage::SwStdFontTabPage(TabPageParent pParent, const SfxItemSet& rSet , m_bSetLabelDefault(true) , m_bIdxDefault(false) , m_bSetIdxDefault(true) + , m_bDisposePrinter(false) , m_bListHeightDefault(false) , m_bLabelHeightDefault(false) , m_bIndexHeightDefault(false) @@ -554,7 +555,10 @@ void SwStdFontTabPage::dispose() m_xTitleHeightLB.reset(); m_xStandardHeightLB.reset(); m_pFontList.reset(); - m_pPrt.clear(); + if (m_bDisposePrinter) + m_pPrt.disposeAndClear(); + else + m_pPrt.clear(); SfxTabPage::dispose(); } @@ -732,6 +736,12 @@ void SwStdFontTabPage::Reset( const SfxItemSet* rSet) const SfxPoolItem* pItem; + if (m_bDisposePrinter) + { + m_pPrt.disposeAndClear(); + m_bDisposePrinter = false; + } + if(SfxItemState::SET == rSet->GetItemState(FN_PARAM_PRINTER, false, &pItem)) { m_pPrt = static_cast<SfxPrinter*>(static_cast<const SwPtrItem*>(pItem)->GetValue()); @@ -742,6 +752,7 @@ void SwStdFontTabPage::Reset( const SfxItemSet* rSet) svl::Items<SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC>{} ); m_pPrt = VclPtr<SfxPrinter>::Create(std::move(pPrinterSet)); + m_bDisposePrinter = true; } m_pFontList.reset(new FontList( m_pPrt )); // #i94536# prevent duplication of font entries when 'reset' button is pressed diff --git a/sw/source/uibase/inc/optpage.hxx b/sw/source/uibase/inc/optpage.hxx index 34cada22ccbd..0a6f191ae32e 100644 --- a/sw/source/uibase/inc/optpage.hxx +++ b/sw/source/uibase/inc/optpage.hxx @@ -142,6 +142,7 @@ class SwStdFontTabPage : public SfxTabPage bool m_bSetLabelDefault :1; bool m_bIdxDefault :1; bool m_bSetIdxDefault :1; + bool m_bDisposePrinter :1; bool m_bListHeightDefault :1; bool m_bLabelHeightDefault :1; |