[Libreoffice-commits] core.git: include/sfx2 sfx2/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sun Jul 15 20:10:30 UTC 2018
include/sfx2/tabdlg.hxx | 6 +++---
sfx2/source/dialog/tabdlg.cxx | 23 ++++++++++-------------
2 files changed, 13 insertions(+), 16 deletions(-)
New commits:
commit b294def2389aa3981a72d23878fa63928efc4147
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun Jul 15 19:43:18 2018 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Sun Jul 15 22:10:10 2018 +0200
coverity#1437960 Resource leak in object
Change-Id: Icee05e1ef1fef213de293971beb9e17753c8eb3b
Reviewed-on: https://gerrit.libreoffice.org/57458
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/sfx2/tabdlg.hxx b/include/sfx2/tabdlg.hxx
index b37370c6bfdf..527151810619 100644
--- a/include/sfx2/tabdlg.hxx
+++ b/include/sfx2/tabdlg.hxx
@@ -241,10 +241,10 @@ private:
std::unique_ptr<weld::Button> m_xResetBtn;
std::unique_ptr<weld::SizeGroup> m_xSizeGroup;
- SfxItemSet* m_pSet;
+ std::unique_ptr<SfxItemSet> m_pSet;
std::unique_ptr<SfxItemSet> m_pOutSet;
- std::unique_ptr< TabDlg_Impl > m_pImpl;
- sal_uInt16* m_pRanges;
+ std::unique_ptr<TabDlg_Impl> m_pImpl;
+ std::unique_ptr<sal_uInt16[]> m_pRanges;
OString m_sAppPageId;
DECL_DLLPRIVATE_LINK(ActivatePageHdl, const OString&, void);
diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index ba7ddb77b900..c337e0b8d465 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -1459,8 +1459,6 @@ SfxTabDialogController::SfxTabDialogController
, m_xCancelBtn(m_xBuilder->weld_button("cancel"))
, m_xResetBtn(m_xBuilder->weld_button("reset"))
, m_pSet(pItemSet ? new SfxItemSet(*pItemSet) : nullptr)
- , m_pOutSet(nullptr)
- , m_pRanges(nullptr)
{
m_pImpl.reset(new TabDlg_Impl(m_xTabCtrl->get_n_pages()));
m_pImpl->bHideResetBtn = !m_xResetBtn->get_visible();
@@ -1538,7 +1536,7 @@ IMPL_LINK_NOARG(SfxTabDialogController, ResetHdl, weld::Button&, void)
Data_Impl* pDataObject = Find( m_pImpl->aData, sId );
DBG_ASSERT( pDataObject, "Id not known" );
- pDataObject->pTabPage->Reset( m_pSet );
+ pDataObject->pTabPage->Reset( m_pSet.get() );
// Also reset relevant items of ExampleSet and OutSet to initial state
if (pDataObject->fnGetRanges)
{
@@ -1608,7 +1606,7 @@ IMPL_LINK(SfxTabDialogController, ActivatePageHdl, const OString&, rPage, void)
return;
if (pDataObject->bRefresh)
- pTabPage->Reset(m_pSet);
+ pTabPage->Reset(m_pSet.get());
pDataObject->bRefresh = false;
if (m_xExampleSet)
@@ -1757,7 +1755,7 @@ const sal_uInt16* SfxTabDialogController::GetInputRanges(const SfxItemPool& rPoo
}
if ( m_pRanges )
- return m_pRanges;
+ return m_pRanges.get();
std::vector<sal_uInt16> aUS;
for (auto const& elem : m_pImpl->aData)
@@ -1787,10 +1785,10 @@ const sal_uInt16* SfxTabDialogController::GetInputRanges(const SfxItemPool& rPoo
std::sort( aUS.begin(), aUS.end() );
}
- m_pRanges = new sal_uInt16[aUS.size() + 1];
- std::copy( aUS.begin(), aUS.end(), m_pRanges );
+ m_pRanges.reset(new sal_uInt16[aUS.size() + 1]);
+ std::copy( aUS.begin(), aUS.end(), m_pRanges.get() );
m_pRanges[aUS.size()] = 0;
- return m_pRanges;
+ return m_pRanges.get();
}
SfxTabDialogController::~SfxTabDialogController()
@@ -1935,7 +1933,7 @@ void SfxTabDialogController::CreatePages()
if (pDataObject->pTabPage)
continue;
weld::Container* pPage = m_xTabCtrl->get_page(pDataObject->sId);
- pDataObject->pTabPage = (pDataObject->fnCreatePage)(pPage, m_pSet);
+ pDataObject->pTabPage = (pDataObject->fnCreatePage)(pPage, m_pSet.get());
pDataObject->pTabPage->SetDialogController(this);
OUString sConfigId = OStringToOUString(pDataObject->pTabPage->GetConfigId(), RTL_TEXTENCODING_UTF8);
@@ -1948,7 +1946,7 @@ void SfxTabDialogController::CreatePages()
pDataObject->pTabPage->SetUserData(sUserData);
PageCreated(pDataObject->sId, *pDataObject->pTabPage);
- pDataObject->pTabPage->Reset(m_pSet);
+ pDataObject->pTabPage->Reset(m_pSet.get());
}
}
@@ -2074,8 +2072,7 @@ void SfxTabDialogController::SetInputSet( const SfxItemSet* pInSet )
{
bool bSet = ( m_pSet != nullptr );
- delete m_pSet;
- m_pSet = pInSet ? new SfxItemSet(*pInSet) : nullptr;
+ m_pSet.reset(pInSet ? new SfxItemSet(*pInSet) : nullptr);
if (!bSet && !m_xExampleSet && !m_pOutSet && m_pSet)
{
@@ -2093,7 +2090,7 @@ SfxItemSet* SfxTabDialogController::GetInputSetImpl()
*/
{
- return m_pSet;
+ return m_pSet.get();
}
void SfxTabDialogController::RemoveResetButton()
More information about the Libreoffice-commits
mailing list