[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - include/sfx2 sfx2/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Jul 17 09:05:31 UTC 2018


 include/sfx2/tabdlg.hxx       |    6 +++---
 sfx2/source/dialog/tabdlg.cxx |   23 ++++++++++-------------
 2 files changed, 13 insertions(+), 16 deletions(-)

New commits:
commit 215de37cd1d860f1e0471319cd8069d51cd8887d
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun Jul 15 19:43:18 2018 +0100
Commit:     Eike Rathke <erack at redhat.com>
CommitDate: Tue Jul 17 11:05:11 2018 +0200

    coverity#1437960 Resource leak in object
    
    Change-Id: Icee05e1ef1fef213de293971beb9e17753c8eb3b
    Reviewed-on: https://gerrit.libreoffice.org/57460
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <erack at redhat.com>

diff --git a/include/sfx2/tabdlg.hxx b/include/sfx2/tabdlg.hxx
index 6e3033500e5a..adc120068153 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 534cef32f2a5..aa1db8c9c3a5 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -1465,8 +1465,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)
 {
     Init_Impl(bEditFmt);
 }
@@ -1549,7 +1547,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)
     {
@@ -1619,7 +1617,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)
@@ -1768,7 +1766,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)
@@ -1798,10 +1796,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()
@@ -1946,7 +1944,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);
@@ -1959,7 +1957,7 @@ void SfxTabDialogController::CreatePages()
         pDataObject->pTabPage->SetUserData(sUserData);
 
         PageCreated(pDataObject->sId, *pDataObject->pTabPage);
-        pDataObject->pTabPage->Reset(m_pSet);
+        pDataObject->pTabPage->Reset(m_pSet.get());
     }
 }
 
@@ -2085,8 +2083,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)
     {
@@ -2104,7 +2101,7 @@ SfxItemSet* SfxTabDialogController::GetInputSetImpl()
 */
 
 {
-    return m_pSet;
+    return m_pSet.get();
 }
 
 void SfxTabDialogController::RemoveResetButton()


More information about the Libreoffice-commits mailing list