Kaydet (Commit) d038d1f5 authored tarafından Caolán McNamara's avatar Caolán McNamara

coverity#1435273 Resource leak in object

Change-Id: I781b2d6f6b550e5b381c041a27d282c4dca9d6dd
Reviewed-on: https://gerrit.libreoffice.org/53805Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 90df301f
...@@ -254,7 +254,7 @@ protected: ...@@ -254,7 +254,7 @@ protected:
virtual void RefreshInputSet(); virtual void RefreshInputSet();
virtual void PageCreated(const OString &rName, SfxTabPage &rPage); virtual void PageCreated(const OString &rName, SfxTabPage &rPage);
SfxItemSet* m_pExampleSet; std::unique_ptr<SfxItemSet> m_xExampleSet;
SfxItemSet* GetInputSetImpl(); SfxItemSet* GetInputSetImpl();
SfxTabPage* GetTabPage(const OString& rPageId) const; SfxTabPage* GetTabPage(const OString& rPageId) const;
...@@ -294,7 +294,7 @@ public: ...@@ -294,7 +294,7 @@ public:
short execute(); short execute();
const SfxItemSet* GetExampleSet() const { return m_pExampleSet; } const SfxItemSet* GetExampleSet() const { return m_xExampleSet.get(); }
SAL_DLLPRIVATE void Start_Impl(); SAL_DLLPRIVATE void Start_Impl();
}; };
......
...@@ -1470,7 +1470,6 @@ SfxTabDialogController::SfxTabDialogController ...@@ -1470,7 +1470,6 @@ SfxTabDialogController::SfxTabDialogController
, m_pSet(pItemSet ? new SfxItemSet(*pItemSet) : nullptr) , m_pSet(pItemSet ? new SfxItemSet(*pItemSet) : nullptr)
, m_pOutSet(nullptr) , m_pOutSet(nullptr)
, m_pRanges(nullptr) , m_pRanges(nullptr)
, m_pExampleSet(nullptr)
{ {
Init_Impl(bEditFmt); Init_Impl(bEditFmt);
} }
...@@ -1492,7 +1491,7 @@ void SfxTabDialogController::Init_Impl(bool /*bFmtFlag*/) ...@@ -1492,7 +1491,7 @@ void SfxTabDialogController::Init_Impl(bool /*bFmtFlag*/)
if (m_pSet) if (m_pSet)
{ {
m_pExampleSet = new SfxItemSet(*m_pSet); m_xExampleSet.reset(new SfxItemSet(*m_pSet));
m_pOutSet.reset(new SfxItemSet(*m_pSet->GetPool(), m_pSet->GetRanges())); m_pOutSet.reset(new SfxItemSet(*m_pSet->GetPool(), m_pSet->GetRanges()));
} }
} }
...@@ -1557,8 +1556,8 @@ IMPL_LINK_NOARG(SfxTabDialogController, ResetHdl, weld::Button&, void) ...@@ -1557,8 +1556,8 @@ IMPL_LINK_NOARG(SfxTabDialogController, ResetHdl, weld::Button&, void)
// Also reset relevant items of ExampleSet and OutSet to initial state // Also reset relevant items of ExampleSet and OutSet to initial state
if (pDataObject->fnGetRanges) if (pDataObject->fnGetRanges)
{ {
if (!m_pExampleSet) if (!m_xExampleSet)
m_pExampleSet = new SfxItemSet(*m_pSet); m_xExampleSet.reset(new SfxItemSet(*m_pSet));
const SfxItemPool* pPool = m_pSet->GetPool(); const SfxItemPool* pPool = m_pSet->GetPool();
const sal_uInt16* pTmpRanges = (pDataObject->fnGetRanges)(); const sal_uInt16* pTmpRanges = (pDataObject->fnGetRanges)();
...@@ -1584,12 +1583,12 @@ IMPL_LINK_NOARG(SfxTabDialogController, ResetHdl, weld::Button&, void) ...@@ -1584,12 +1583,12 @@ IMPL_LINK_NOARG(SfxTabDialogController, ResetHdl, weld::Button&, void)
const SfxPoolItem* pItem; const SfxPoolItem* pItem;
if (SfxItemState::SET == m_pSet->GetItemState(nWh, false, &pItem)) if (SfxItemState::SET == m_pSet->GetItemState(nWh, false, &pItem))
{ {
m_pExampleSet->Put(*pItem); m_xExampleSet->Put(*pItem);
m_pOutSet->Put(*pItem); m_pOutSet->Put(*pItem);
} }
else else
{ {
m_pExampleSet->ClearItem(nWh); m_xExampleSet->ClearItem(nWh);
m_pOutSet->ClearItem(nWh); m_pOutSet->ClearItem(nWh);
} }
nTmp++; nTmp++;
...@@ -1624,8 +1623,8 @@ IMPL_LINK(SfxTabDialogController, ActivatePageHdl, const OString&, rPage, void) ...@@ -1624,8 +1623,8 @@ IMPL_LINK(SfxTabDialogController, ActivatePageHdl, const OString&, rPage, void)
pTabPage->Reset(m_pSet); pTabPage->Reset(m_pSet);
pDataObject->bRefresh = false; pDataObject->bRefresh = false;
if (m_pExampleSet) if (m_xExampleSet)
pTabPage->ActivatePage(*m_pExampleSet); pTabPage->ActivatePage(*m_xExampleSet);
if (pTabPage->IsReadOnly() || m_pImpl->bHideResetBtn) if (pTabPage->IsReadOnly() || m_pImpl->bHideResetBtn)
m_xResetBtn->hide(); m_xResetBtn->hide();
...@@ -1660,8 +1659,8 @@ IMPL_LINK(SfxTabDialogController, DeactivatePageHdl, const OString&, rPage, bool ...@@ -1660,8 +1659,8 @@ IMPL_LINK(SfxTabDialogController, DeactivatePageHdl, const OString&, rPage, bool
DeactivateRC nRet = DeactivateRC::LeavePage; DeactivateRC nRet = DeactivateRC::LeavePage;
if (!m_pExampleSet && pPage->HasExchangeSupport() && m_pSet) if (!m_xExampleSet && pPage->HasExchangeSupport() && m_pSet)
m_pExampleSet = new SfxItemSet(*m_pSet->GetPool(), m_pSet->GetRanges()); m_xExampleSet.reset(new SfxItemSet(*m_pSet->GetPool(), m_pSet->GetRanges()));
if (m_pSet) if (m_pSet)
{ {
...@@ -1672,9 +1671,9 @@ IMPL_LINK(SfxTabDialogController, DeactivatePageHdl, const OString&, rPage, bool ...@@ -1672,9 +1671,9 @@ IMPL_LINK(SfxTabDialogController, DeactivatePageHdl, const OString&, rPage, bool
else else
nRet = pPage->DeactivatePage(nullptr); nRet = pPage->DeactivatePage(nullptr);
if ( ( DeactivateRC::LeavePage & nRet ) == DeactivateRC::LeavePage && if ( ( DeactivateRC::LeavePage & nRet ) == DeactivateRC::LeavePage &&
aTmp.Count() && m_pExampleSet) aTmp.Count() && m_xExampleSet)
{ {
m_pExampleSet->Put( aTmp ); m_xExampleSet->Put( aTmp );
m_pOutSet->Put( aTmp ); m_pOutSet->Put( aTmp );
} }
} }
...@@ -1682,13 +1681,12 @@ IMPL_LINK(SfxTabDialogController, DeactivatePageHdl, const OString&, rPage, bool ...@@ -1682,13 +1681,12 @@ IMPL_LINK(SfxTabDialogController, DeactivatePageHdl, const OString&, rPage, bool
{ {
if ( pPage->HasExchangeSupport() ) //!!! if ( pPage->HasExchangeSupport() ) //!!!
{ {
if ( !m_pExampleSet ) if (!m_xExampleSet)
{ {
SfxItemPool* pPool = pPage->GetItemSet().GetPool(); SfxItemPool* pPool = pPage->GetItemSet().GetPool();
m_pExampleSet = m_xExampleSet.reset(new SfxItemSet(*pPool, GetInputRanges(*pPool)));
new SfxItemSet( *pPool, GetInputRanges( *pPool ) );
} }
nRet = pPage->DeactivatePage( m_pExampleSet ); nRet = pPage->DeactivatePage(m_xExampleSet.get());
} }
else else
nRet = pPage->DeactivatePage( nullptr ); nRet = pPage->DeactivatePage( nullptr );
...@@ -1731,7 +1729,7 @@ bool SfxTabDialogController::PrepareLeaveCurrentPage() ...@@ -1731,7 +1729,7 @@ bool SfxTabDialogController::PrepareLeaveCurrentPage()
if ( ( DeactivateRC::LeavePage & nRet ) == DeactivateRC::LeavePage if ( ( DeactivateRC::LeavePage & nRet ) == DeactivateRC::LeavePage
&& aTmp.Count() ) && aTmp.Count() )
{ {
m_pExampleSet->Put( aTmp ); m_xExampleSet->Put( aTmp );
m_pOutSet->Put( aTmp ); m_pOutSet->Put( aTmp );
} }
} }
...@@ -1857,8 +1855,8 @@ short SfxTabDialogController::Ok() ...@@ -1857,8 +1855,8 @@ short SfxTabDialogController::Ok()
if ( !m_pOutSet ) if ( !m_pOutSet )
{ {
if ( m_pExampleSet ) if ( m_xExampleSet )
m_pOutSet.reset(new SfxItemSet( *m_pExampleSet )); m_pOutSet.reset(new SfxItemSet( *m_xExampleSet ));
else if ( m_pSet ) else if ( m_pSet )
m_pOutSet = m_pSet->Clone( false ); // without Items m_pOutSet = m_pSet->Clone( false ); // without Items
} }
...@@ -1877,8 +1875,8 @@ short SfxTabDialogController::Ok() ...@@ -1877,8 +1875,8 @@ short SfxTabDialogController::Ok()
if ( pTabPage->FillItemSet( &aTmp ) ) if ( pTabPage->FillItemSet( &aTmp ) )
{ {
bModified = true; bModified = true;
if (m_pExampleSet) if (m_xExampleSet)
m_pExampleSet->Put( aTmp ); m_xExampleSet->Put( aTmp );
m_pOutSet->Put( aTmp ); m_pOutSet->Put( aTmp );
} }
} }
...@@ -2035,9 +2033,9 @@ void SfxTabDialogController::SetInputSet( const SfxItemSet* pInSet ) ...@@ -2035,9 +2033,9 @@ void SfxTabDialogController::SetInputSet( const SfxItemSet* pInSet )
delete m_pSet; delete m_pSet;
m_pSet = pInSet ? new SfxItemSet(*pInSet) : nullptr; m_pSet = pInSet ? new SfxItemSet(*pInSet) : nullptr;
if (!bSet && !m_pExampleSet && !m_pOutSet && m_pSet) if (!bSet && !m_xExampleSet && !m_pOutSet && m_pSet)
{ {
m_pExampleSet = new SfxItemSet( *m_pSet ); m_xExampleSet.reset(new SfxItemSet(*m_pSet));
m_pOutSet.reset(new SfxItemSet( *m_pSet->GetPool(), m_pSet->GetRanges() )); m_pOutSet.reset(new SfxItemSet( *m_pSet->GetPool(), m_pSet->GetRanges() ));
} }
} }
......
...@@ -135,8 +135,8 @@ SwLabDlg::SwLabDlg(weld::Window* pParent, const SfxItemSet& rSet, ...@@ -135,8 +135,8 @@ SwLabDlg::SwLabDlg(weld::Window* pParent, const SfxItemSet& rSet,
if ( !aMakes.empty() ) if ( !aMakes.empty() )
ReplaceGroup_( aMakes[nLstGroup] ); ReplaceGroup_( aMakes[nLstGroup] );
if (m_pExampleSet) if (m_xExampleSet)
m_pExampleSet->Put(aItem); m_xExampleSet->Put(aItem);
AddTabPage("format", SwLabFormatPage::Create, nullptr); AddTabPage("format", SwLabFormatPage::Create, nullptr);
AddTabPage("options", SwLabPrtPage::Create, nullptr); AddTabPage("options", SwLabPrtPage::Create, nullptr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment