[Libreoffice-commits] core.git: 2 commits - include/sfx2 sfx2/source

Noel Grandin noel.grandin at collabora.co.uk
Mon May 7 06:31:54 UTC 2018


 include/sfx2/basedlgs.hxx       |    6 +++---
 sfx2/source/dialog/basedlgs.cxx |    4 ++--
 sfx2/source/dialog/versdlg.cxx  |   25 +++++++++++--------------
 sfx2/source/inc/versdlg.hxx     |    2 +-
 4 files changed, 17 insertions(+), 20 deletions(-)

New commits:
commit 063ac5c39a8ba324ca14384065df1118e44fabd5
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu May 3 14:08:54 2018 +0200

    loplugin:useuniqueptr in SfxVersionDialog
    
    Change-Id: I6adb8baff9792c65e3474c10e6ffdac56fe2e5ff
    Reviewed-on: https://gerrit.libreoffice.org/53869
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sfx2/source/dialog/versdlg.cxx b/sfx2/source/dialog/versdlg.cxx
index ff3dcb81ef6b..f268bfeef031 100644
--- a/sfx2/source/dialog/versdlg.cxx
+++ b/sfx2/source/dialog/versdlg.cxx
@@ -270,20 +270,17 @@ void SfxVersionDialog::Init_Impl()
     SfxObjectShell *pObjShell = pViewFrame->GetObjectShell();
     SfxMedium* pMedium = pObjShell->GetMedium();
     uno::Sequence < util::RevisionTag > aVersions = pMedium->GetVersionList( true );
-    delete m_pTable;
-    m_pTable = new SfxVersionTableDtor( aVersions );
+    m_pTable.reset(new SfxVersionTableDtor( aVersions ));
+    for ( size_t n = 0; n < m_pTable->size(); ++n )
     {
-        for ( size_t n = 0; n < m_pTable->size(); ++n )
-        {
-            SfxVersionInfo *pInfo = m_pTable->at( n );
-            OUString aEntry = formatTime(pInfo->aCreationDate, Application::GetSettings().GetLocaleDataWrapper());
-            aEntry += "\t";
-            aEntry += pInfo->aAuthor;
-            aEntry += "\t";
-            aEntry += ConvertWhiteSpaces_Impl( pInfo->aComment );
-            SvTreeListEntry *pEntry = m_pVersionBox->InsertEntry( aEntry );
-            pEntry->SetUserData( pInfo );
-        }
+        SfxVersionInfo *pInfo = m_pTable->at( n );
+        OUString aEntry = formatTime(pInfo->aCreationDate, Application::GetSettings().GetLocaleDataWrapper());
+        aEntry += "\t";
+        aEntry += pInfo->aAuthor;
+        aEntry += "\t";
+        aEntry += ConvertWhiteSpaces_Impl( pInfo->aComment );
+        SvTreeListEntry *pEntry = m_pVersionBox->InsertEntry( aEntry );
+        pEntry->SetUserData( pInfo );
     }
 
     m_pSaveCheckBox->Check( m_bIsSaveVersionOnClose );
@@ -312,7 +309,7 @@ SfxVersionDialog::~SfxVersionDialog()
 
 void SfxVersionDialog::dispose()
 {
-    delete m_pTable;
+    m_pTable.reset();
     m_pVersionBox.disposeAndClear();
     m_pSaveButton.clear();
     m_pSaveCheckBox.clear();
diff --git a/sfx2/source/inc/versdlg.hxx b/sfx2/source/inc/versdlg.hxx
index 4d81c139a1e9..b35d3fa36b9d 100644
--- a/sfx2/source/inc/versdlg.hxx
+++ b/sfx2/source/inc/versdlg.hxx
@@ -55,7 +55,7 @@ class SfxVersionDialog : public SfxModalDialog
     VclPtr<PushButton>                 m_pCompareButton;
     VclPtr<PushButton>                 m_pCmisButton;
     SfxViewFrame*               pViewFrame;
-    SfxVersionTableDtor*        m_pTable;
+    std::unique_ptr<SfxVersionTableDtor> m_pTable;
     bool                        m_bIsSaveVersionOnClose;
 
     DECL_LINK(            DClickHdl_Impl, SvTreeListBox*, bool);
commit 8ffd83de107adfcc7a18bde6e8337c90924b89b7
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu May 3 14:05:30 2018 +0200

    loplugin:useuniqueptr in SfxModalDialog
    
    Change-Id: I612b92045c3a1cf4a443adf2b35fe7ac6f1aa0bf
    Reviewed-on: https://gerrit.libreoffice.org/53868
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/sfx2/basedlgs.hxx b/include/sfx2/basedlgs.hxx
index e5110415dcf4..58657fc58e8b 100644
--- a/include/sfx2/basedlgs.hxx
+++ b/include/sfx2/basedlgs.hxx
@@ -47,7 +47,7 @@ class SFX2_DLLPUBLIC SfxModalDialog: public ModalDialog
 {
     OUString                aExtraData;
     const SfxItemSet*       pInputSet;
-    SfxItemSet*             pOutputSet;
+    std::unique_ptr<SfxItemSet> pOutputSet;
 
 private:
     SfxModalDialog(SfxModalDialog &) = delete;
@@ -62,13 +62,13 @@ protected:
     OUString&           GetExtraData()      { return aExtraData; }
     void                CreateOutputItemSet( const SfxItemSet& rInput );
     void                SetInputSet( const SfxItemSet* pInSet ) { pInputSet = pInSet; }
-    SfxItemSet*         GetOutputSetImpl() { return pOutputSet; }
+    SfxItemSet*         GetOutputSetImpl() { return pOutputSet.get(); }
 
 public:
     virtual ~SfxModalDialog() override;
     virtual void dispose() override;
 
-    const SfxItemSet*   GetOutputItemSet() const { return pOutputSet; }
+    const SfxItemSet*   GetOutputItemSet() const { return pOutputSet.get(); }
     const SfxItemSet*   GetInputItemSet() const { return pInputSet; }
     void                StateChanged( StateChangedType nStateChange ) override;
 };
diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index beb615a60d60..9aa81f460a2a 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -138,7 +138,7 @@ SfxModalDialog::~SfxModalDialog()
 void SfxModalDialog::dispose()
 {
     SetDialogData_Impl();
-    delete pOutputSet;
+    pOutputSet.reset();
 
     ModalDialog::dispose();
 }
@@ -148,7 +148,7 @@ void SfxModalDialog::CreateOutputItemSet( const SfxItemSet& rSet )
     DBG_ASSERT( !pOutputSet, "Double creation of OutputSet!" );
     if (!pOutputSet)
     {
-        pOutputSet = new SfxItemSet( rSet );
+        pOutputSet.reset(new SfxItemSet( rSet ));
         pOutputSet->ClearItem();
     }
 }


More information about the Libreoffice-commits mailing list