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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Dec 12 08:54:32 UTC 2018


 include/sfx2/childwin.hxx                |   11 +++++------
 sc/source/ui/inc/ChildWindowWrapper.hxx  |    5 ++---
 sfx2/source/appl/childwin.cxx            |    6 +++---
 sfx2/source/appl/workwin.cxx             |    2 +-
 sfx2/source/dialog/dockwin.cxx           |    5 ++---
 sw/source/uibase/inc/idxmrk.hxx          |    4 ++--
 sw/source/uibase/inc/wordcountdialog.hxx |    2 +-
 7 files changed, 16 insertions(+), 19 deletions(-)

New commits:
commit 0bab9c02285ead494edbc456a96f38545823bb10
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Dec 12 09:47:18 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Dec 12 09:54:07 2018 +0100

    use unique_ptr in SfxChildWinCtor
    
    Change-Id: I155036f6a47c765595938ff325ede6bbe6dd5c48
    Reviewed-on: https://gerrit.libreoffice.org/65000
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/sfx2/childwin.hxx b/include/sfx2/childwin.hxx
index 3ddc7a377dae..03f7f20292b2 100644
--- a/include/sfx2/childwin.hxx
+++ b/include/sfx2/childwin.hxx
@@ -82,7 +82,7 @@ struct SAL_DLLPUBLIC_RTTI SfxChildWinInfo
 };
 
 // ChildWindow factory methods
-typedef SfxChildWindow* (*SfxChildWinCtor)( vcl::Window *pParentWindow,
+typedef std::unique_ptr<SfxChildWindow> (*SfxChildWinCtor)( vcl::Window *pParentWindow,
                                             sal_uInt16 nId,
                                             SfxBindings *pBindings,
                                             SfxChildWinInfo *pInfo);
@@ -193,7 +193,7 @@ public:
 
     static void         RegisterChildWindow(SfxModule*, std::unique_ptr<SfxChildWinFactory>);
 
-    static SfxChildWindow* CreateChildWindow( sal_uInt16, vcl::Window*, SfxBindings*, SfxChildWinInfo const &);
+    static std::unique_ptr<SfxChildWindow> CreateChildWindow( sal_uInt16, vcl::Window*, SfxBindings*, SfxChildWinInfo const &);
     void                SetHideNotDelete( bool bOn );
     bool                IsHideNotDelete() const;
     bool                IsVisible() const;
@@ -242,7 +242,7 @@ public:
 
 #define SFX_DECL_CHILDWINDOW(Class) \
     public  :   \
-        static  SfxChildWindow* CreateImpl(vcl::Window *pParent, sal_uInt16 nId, \
+        static  std::unique_ptr<SfxChildWindow> CreateImpl(vcl::Window *pParent, sal_uInt16 nId, \
                     SfxBindings *pBindings, SfxChildWinInfo* pInfo ); \
         static  void RegisterChildWindow (bool bVisible=false, SfxModule *pMod=nullptr, SfxChildWindowFlags nFlags=SfxChildWindowFlags::NONE); \
         virtual SfxChildWinInfo GetInfo() const override
@@ -258,11 +258,10 @@ public:
         SFX_IMPL_POS_CHILDWINDOW_WITHID(Class, MyID, CHILDWIN_NOPOS)
 
 #define SFX_IMPL_POS_CHILDWINDOW(Class, MyID, Pos) \
-        SfxChildWindow* Class::CreateImpl( vcl::Window *pParent, \
+        std::unique_ptr<SfxChildWindow> Class::CreateImpl( vcl::Window *pParent, \
                 sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo* pInfo ) \
                 {   \
-                    SfxChildWindow *pWin = new Class(pParent, nId, pBindings, pInfo);\
-                    return pWin; \
+                    return o3tl::make_unique<Class>(pParent, nId, pBindings, pInfo);\
                 } \
         void    Class::RegisterChildWindow (bool bVis, SfxModule *pMod, SfxChildWindowFlags nFlags)   \
                 {   \
diff --git a/sc/source/ui/inc/ChildWindowWrapper.hxx b/sc/source/ui/inc/ChildWindowWrapper.hxx
index db6d0c70f73e..89bf560499d2 100644
--- a/sc/source/ui/inc/ChildWindowWrapper.hxx
+++ b/sc/source/ui/inc/ChildWindowWrapper.hxx
@@ -40,12 +40,11 @@ public:
             pViewShell->GetViewFrame()->SetChildWindow( nId, false );
     }
 
-    static SfxChildWindow* CreateImpl(
+    static std::unique_ptr<SfxChildWindow> CreateImpl(
                 vcl::Window *pParent, sal_uInt16 nId,
                 SfxBindings *pBindings, SfxChildWinInfo* pInfo )
     {
-        SfxChildWindow* pWindow = new ChildWindowWrapper(pParent, nId, pBindings, pInfo);
-        return pWindow;
+        return o3tl::make_unique<ChildWindowWrapper>(pParent, nId, pBindings, pInfo);
     }
 
     static void RegisterChildWindow (
diff --git a/sfx2/source/appl/childwin.cxx b/sfx2/source/appl/childwin.cxx
index 2c53919f1c38..70dc1e7f3996 100644
--- a/sfx2/source/appl/childwin.cxx
+++ b/sfx2/source/appl/childwin.cxx
@@ -201,10 +201,10 @@ SfxChildWindow::~SfxChildWindow()
 }
 
 
-SfxChildWindow* SfxChildWindow::CreateChildWindow( sal_uInt16 nId,
+std::unique_ptr<SfxChildWindow> SfxChildWindow::CreateChildWindow( sal_uInt16 nId,
         vcl::Window *pParent, SfxBindings* pBindings, SfxChildWinInfo const & rInfo)
 {
-    SfxChildWindow *pChild=nullptr;
+    std::unique_ptr<SfxChildWindow> pChild;
     SfxChildWinFactory* pFact=nullptr;
     SystemWindowFlags nOldMode = Application::GetSystemWindowMode();
 
@@ -275,7 +275,7 @@ SfxChildWindow* SfxChildWindow::CreateChildWindow( sal_uInt16 nId,
 
     if (pChild && (!pChild->pWindow && !pChild->xController))
     {
-        DELETEZ(pChild);
+        pChild.reset();
         SAL_INFO("sfx.appl", "ChildWindow has no Window!");
     }
 
diff --git a/sfx2/source/appl/workwin.cxx b/sfx2/source/appl/workwin.cxx
index b7f6eddd9777..419b2b4d6d17 100644
--- a/sfx2/source/appl/workwin.cxx
+++ b/sfx2/source/appl/workwin.cxx
@@ -1337,7 +1337,7 @@ void SfxWorkWindow::CreateChildWin_Impl( SfxChildWin_Impl *pCW, bool bSetFocus )
 {
     pCW->aInfo.bVisible = true;
 
-    SfxChildWindow *pChildWin = SfxChildWindow::CreateChildWindow( pCW->nId, pWorkWin, &GetBindings(), pCW->aInfo);
+    SfxChildWindow *pChildWin = SfxChildWindow::CreateChildWindow( pCW->nId, pWorkWin, &GetBindings(), pCW->aInfo).release();
     if (pChildWin)
     {
         if ( bSetFocus )
diff --git a/sfx2/source/dialog/dockwin.cxx b/sfx2/source/dialog/dockwin.cxx
index 5df504293d0e..1297ff1358e2 100644
--- a/sfx2/source/dialog/dockwin.cxx
+++ b/sfx2/source/dialog/dockwin.cxx
@@ -203,11 +203,10 @@ SfxDockingWrapper::SfxDockingWrapper( vcl::Window* pParentWnd ,
     SetHideNotDelete( true );
 }
 
-SfxChildWindow* SfxDockingWrapper::CreateImpl(vcl::Window *pParent, sal_uInt16 nId,
+std::unique_ptr<SfxChildWindow> SfxDockingWrapper::CreateImpl(vcl::Window *pParent, sal_uInt16 nId,
                                               SfxBindings *pBindings, SfxChildWinInfo* pInfo)
 {
-    SfxChildWindow *pWin = new SfxDockingWrapper(pParent, nId, pBindings, pInfo);
-    return pWin;
+    return o3tl::make_unique<SfxDockingWrapper>(pParent, nId, pBindings, pInfo);
 }
 
 void SfxDockingWrapper::RegisterChildWindow (bool bVis, SfxModule *pMod, SfxChildWindowFlags nFlags)
diff --git a/sw/source/uibase/inc/idxmrk.hxx b/sw/source/uibase/inc/idxmrk.hxx
index 26268026c04e..e180ebed2ffa 100644
--- a/sw/source/uibase/inc/idxmrk.hxx
+++ b/sw/source/uibase/inc/idxmrk.hxx
@@ -29,6 +29,7 @@ class SwInsertIdxMarkWrapper final : public SfxChildWindow
 {
     ScopedVclPtr<AbstractMarkFloatDlg> xAbstDlg;
 
+public:
     SwInsertIdxMarkWrapper(vcl::Window *pParentWindow,
                            sal_uInt16 nId,
                            SfxBindings* pBindings,
@@ -36,7 +37,6 @@ class SwInsertIdxMarkWrapper final : public SfxChildWindow
 
     SFX_DECL_CHILDWINDOW_WITHID(SwInsertIdxMarkWrapper);
 
-public:
     void    ReInitDlg(SwWrtShell& rWrtShell);
 };
 
@@ -44,6 +44,7 @@ class SwInsertAuthMarkWrapper final : public SfxChildWindow
 {
     ScopedVclPtr<AbstractMarkFloatDlg> xAbstDlg;
 
+public:
     SwInsertAuthMarkWrapper(vcl::Window *pParentWindow,
                             sal_uInt16 nId,
                             SfxBindings* pBindings,
@@ -51,7 +52,6 @@ class SwInsertAuthMarkWrapper final : public SfxChildWindow
 
     SFX_DECL_CHILDWINDOW_WITHID(SwInsertAuthMarkWrapper);
 
-public:
     void    ReInitDlg(SwWrtShell& rWrtShell);
 };
 
diff --git a/sw/source/uibase/inc/wordcountdialog.hxx b/sw/source/uibase/inc/wordcountdialog.hxx
index 7e2730f7d0aa..117a840a9db8 100644
--- a/sw/source/uibase/inc/wordcountdialog.hxx
+++ b/sw/source/uibase/inc/wordcountdialog.hxx
@@ -59,13 +59,13 @@ class SwWordCountWrapper final : public SfxChildWindow
 {
     VclPtr<AbstractSwWordCountFloatDlg> xAbstDlg;
 
+public:
     SwWordCountWrapper(    vcl::Window *pParentWindow,
                             sal_uInt16 nId,
                             SfxBindings* pBindings,
                             SfxChildWinInfo* pInfo );
     SFX_DECL_CHILDWINDOW_WITHID(SwWordCountWrapper);
 
-public:
     virtual ~SwWordCountWrapper() override;
     void    UpdateCounts();
     void    SetCounts(const SwDocStat &rCurrCnt, const SwDocStat &rDocStat);


More information about the Libreoffice-commits mailing list