[Libreoffice-commits] core.git: include/vcl vcl/inc vcl/osx vcl/qt5 vcl/source vcl/unx vcl/win

Noel Grandin noel.grandin at collabora.co.uk
Sat Jun 9 11:13:08 UTC 2018


 include/vcl/menu.hxx          |    4 ++--
 vcl/inc/osx/salinst.h         |    3 +--
 vcl/inc/qt5/Qt5Instance.hxx   |    3 +--
 vcl/inc/salinst.hxx           |    3 +--
 vcl/inc/unx/gtk/gtkinst.hxx   |    3 +--
 vcl/inc/win/salinst.h         |    3 +--
 vcl/osx/salmenu.cxx           |    9 ++-------
 vcl/qt5/Qt5Instance.cxx       |    6 ++----
 vcl/source/app/salvtables.cxx |    7 +------
 vcl/source/window/menu.cxx    |    4 +---
 vcl/unx/gtk/gtkinst.cxx       |   13 +++----------
 vcl/win/window/salmenu.cxx    |    9 ++-------
 12 files changed, 18 insertions(+), 49 deletions(-)

New commits:
commit 7d521a85858bacdb7b5db359036ccf6f01b709c3
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Fri Jun 8 14:41:16 2018 +0200

    hold and return SalMenu by std::unique_ptr
    
    and drop DestroyMenu, all the implementations just delete the object
    
    Change-Id: I673997ea1a9c5216b100cafdc70a8f697732769b
    Reviewed-on: https://gerrit.libreoffice.org/55501
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx
index 6c73d802802f..705486ab7356 100644
--- a/include/vcl/menu.hxx
+++ b/include/vcl/menu.hxx
@@ -157,7 +157,7 @@ private:
 
     css::uno::Reference<css::accessibility::XAccessible > mxAccessible;
     mutable std::unique_ptr<vcl::MenuLayoutData> mpLayoutData;
-    SalMenu* mpSalMenu;
+    std::unique_ptr<SalMenu> mpSalMenu;
 
 protected:
     SAL_DLLPRIVATE Menu* ImplGetStartMenu();
@@ -181,7 +181,7 @@ protected:
     DECL_DLLPRIVATE_LINK(ImplCallSelect, void*, void );
 
     SAL_DLLPRIVATE void ImplFillLayoutData() const;
-    SAL_DLLPRIVATE SalMenu* ImplGetSalMenu() { return mpSalMenu; }
+    SAL_DLLPRIVATE SalMenu* ImplGetSalMenu() { return mpSalMenu.get(); }
     SAL_DLLPRIVATE void ImplClearSalMenu();
     SAL_DLLPRIVATE OUString ImplGetHelpText( sal_uInt16 nItemId ) const;
 
diff --git a/vcl/inc/osx/salinst.h b/vcl/inc/osx/salinst.h
index a19e9e423f9b..fa15a5cb7bca 100644
--- a/vcl/inc/osx/salinst.h
+++ b/vcl/inc/osx/salinst.h
@@ -118,8 +118,7 @@ public:
     virtual void            AcquireYieldMutex( sal_uInt32 nCount = 1 ) override;
     virtual bool            DoYield(bool bWait, bool bHandleAllCurrentEvents) override;
     virtual bool            AnyInput( VclInputFlags nType ) override;
-    virtual SalMenu*        CreateMenu( bool bMenuBar, Menu* pVCLMenu ) override;
-    virtual void            DestroyMenu( SalMenu* ) override;
+    virtual std::unique_ptr<SalMenu>     CreateMenu( bool bMenuBar, Menu* pVCLMenu ) override;
     virtual std::unique_ptr<SalMenuItem> CreateMenuItem( const SalItemParams & rItemData ) override;
     virtual OpenGLContext*  CreateOpenGLContext() override;
     virtual OUString        GetConnectionIdentifier() override;
diff --git a/vcl/inc/qt5/Qt5Instance.hxx b/vcl/inc/qt5/Qt5Instance.hxx
index 16e22098cd09..06f9c7d4102c 100644
--- a/vcl/inc/qt5/Qt5Instance.hxx
+++ b/vcl/inc/qt5/Qt5Instance.hxx
@@ -80,8 +80,7 @@ public:
     virtual OUString GetDefaultPrinter() override;
     virtual void PostPrintersChanged() override;
 
-    virtual SalMenu* CreateMenu(bool, Menu*) override;
-    virtual void DestroyMenu(SalMenu* pMenu) override;
+    virtual std::unique_ptr<SalMenu> CreateMenu(bool, Menu*) override;
     virtual std::unique_ptr<SalMenuItem> CreateMenuItem(const SalItemParams&) override;
 
     virtual SalTimer* CreateSalTimer() override;
diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx
index 3924ee3d497f..fa4fa92d3289 100644
--- a/vcl/inc/salinst.hxx
+++ b/vcl/inc/salinst.hxx
@@ -152,8 +152,7 @@ public:
     virtual bool           AnyInput( VclInputFlags nType ) = 0;
 
     // menus
-    virtual SalMenu*        CreateMenu( bool bMenuBar, Menu* pMenu );
-    virtual void            DestroyMenu( SalMenu* pMenu);
+    virtual std::unique_ptr<SalMenu>     CreateMenu( bool bMenuBar, Menu* pMenu );
     virtual std::unique_ptr<SalMenuItem> CreateMenuItem( const SalItemParams& pItemData );
 
     // may return NULL to disable session management, only used by X11 backend
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx
index 499bacadd5b4..5f8534ae262f 100644
--- a/vcl/inc/unx/gtk/gtkinst.hxx
+++ b/vcl/inc/unx/gtk/gtkinst.hxx
@@ -198,8 +198,7 @@ public:
     virtual SalSystem*          CreateSalSystem() override;
     virtual SalInfoPrinter*     CreateInfoPrinter(SalPrinterQueueInfo* pPrinterQueueInfo, ImplJobSetup* pJobSetup) override;
     virtual std::unique_ptr<SalPrinter> CreatePrinter( SalInfoPrinter* pInfoPrinter ) override;
-    virtual SalMenu*            CreateMenu( bool, Menu* ) override;
-    virtual void                DestroyMenu( SalMenu* pMenu ) override;
+    virtual std::unique_ptr<SalMenu>     CreateMenu( bool, Menu* ) override;
     virtual std::unique_ptr<SalMenuItem> CreateMenuItem( const SalItemParams& ) override;
     virtual SalTimer*           CreateSalTimer() override;
     virtual void                AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) override;
diff --git a/vcl/inc/win/salinst.h b/vcl/inc/win/salinst.h
index e96fbc5b56b0..f0df23433d10 100644
--- a/vcl/inc/win/salinst.h
+++ b/vcl/inc/win/salinst.h
@@ -72,8 +72,7 @@ public:
 
     virtual bool                DoYield(bool bWait, bool bHandleAllCurrentEvents) override;
     virtual bool                AnyInput( VclInputFlags nType ) override;
-    virtual SalMenu*            CreateMenu( bool bMenuBar, Menu* ) override;
-    virtual void                DestroyMenu( SalMenu* ) override;
+    virtual std::unique_ptr<SalMenu>     CreateMenu( bool bMenuBar, Menu* ) override;
     virtual std::unique_ptr<SalMenuItem> CreateMenuItem( const SalItemParams & rItemData ) override;
     virtual OpenGLContext*      CreateOpenGLContext() override;
     virtual OUString            GetConnectionIdentifier() override;
diff --git a/vcl/osx/salmenu.cxx b/vcl/osx/salmenu.cxx
index ff400fdd4810..1cbdd979d56e 100644
--- a/vcl/osx/salmenu.cxx
+++ b/vcl/osx/salmenu.cxx
@@ -218,19 +218,14 @@ SAL_WNODEPRECATED_DECLARATIONS_POP
     }
 }
 
-SalMenu* AquaSalInstance::CreateMenu( bool bMenuBar, Menu* pVCLMenu )
+std::unique_ptr<SalMenu> AquaSalInstance::CreateMenu( bool bMenuBar, Menu* pVCLMenu )
 {
     initAppMenu();
 
     AquaSalMenu *pAquaSalMenu = new AquaSalMenu( bMenuBar );
     pAquaSalMenu->mpVCLMenu = pVCLMenu;
 
-    return pAquaSalMenu;
-}
-
-void AquaSalInstance::DestroyMenu( SalMenu* pSalMenu )
-{
-    delete pSalMenu;
+    return std::unique_ptr<SalMenu>(pAquaSalMenu);
 }
 
 std::unique_ptr<SalMenuItem> AquaSalInstance::CreateMenuItem( const SalItemParams & rItemData )
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index 705137c16c50..6bc3694883b3 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -111,15 +111,13 @@ Qt5Instance::CreateVirtualDevice(SalGraphics* pGraphics, long& nDX, long& nDY, D
     }
 }
 
-SalMenu* Qt5Instance::CreateMenu(bool bMenuBar, Menu* pVCLMenu)
+std::unique_ptr<SalMenu> Qt5Instance::CreateMenu(bool bMenuBar, Menu* pVCLMenu)
 {
     Qt5Menu* pSalMenu = new Qt5Menu(bMenuBar);
     pSalMenu->SetMenu(pVCLMenu);
-    return pSalMenu;
+    return std::unique_ptr<SalMenu>(pSalMenu);
 }
 
-void Qt5Instance::DestroyMenu(SalMenu* pMenu) { delete pMenu; }
-
 std::unique_ptr<SalMenuItem> Qt5Instance::CreateMenuItem(const SalItemParams& rItemData)
 {
     return std::unique_ptr<SalMenuItem>(new Qt5MenuItem(&rItemData));
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index d5ac7c95e513..00ff6c6a9090 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -87,17 +87,12 @@ std::unique_ptr<SalSession> SalInstance::CreateSalSession()
     return nullptr;
 }
 
-SalMenu* SalInstance::CreateMenu( bool, Menu* )
+std::unique_ptr<SalMenu> SalInstance::CreateMenu( bool, Menu* )
 {
     // default: no native menus
     return nullptr;
 }
 
-void SalInstance::DestroyMenu( SalMenu* pMenu )
-{
-    OSL_ENSURE( pMenu == nullptr, "DestroyMenu called with non-native menus" );
-}
-
 std::unique_ptr<SalMenuItem> SalInstance::CreateMenuItem( const SalItemParams & )
 {
     return nullptr;
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index ce19d83b85de..cf509a91374a 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -2302,9 +2302,7 @@ OUString Menu::GetAccessibleName( sal_uInt16 nItemId ) const
 
 void Menu::ImplClearSalMenu()
 {
-    if( mpSalMenu )
-        ImplGetSVData()->mpDefInst->DestroyMenu( mpSalMenu );
-    mpSalMenu = nullptr;
+    mpSalMenu.reset();
 }
 
 void Menu::GetSystemMenuData( SystemMenuData* pData ) const
diff --git a/vcl/unx/gtk/gtkinst.cxx b/vcl/unx/gtk/gtkinst.cxx
index e61acedf3cd9..4cf31b82312a 100644
--- a/vcl/unx/gtk/gtkinst.cxx
+++ b/vcl/unx/gtk/gtkinst.cxx
@@ -357,18 +357,12 @@ SalBitmap* GtkInstance::CreateSalBitmap()
 
 #ifdef ENABLE_GMENU_INTEGRATION
 
-SalMenu* GtkInstance::CreateMenu( bool bMenuBar, Menu* pVCLMenu )
+std::unique_ptr<SalMenu> GtkInstance::CreateMenu( bool bMenuBar, Menu* pVCLMenu )
 {
     EnsureInit();
     GtkSalMenu* pSalMenu = new GtkSalMenu( bMenuBar );
     pSalMenu->SetMenu( pVCLMenu );
-    return pSalMenu;
-}
-
-void GtkInstance::DestroyMenu( SalMenu* pMenu )
-{
-    EnsureInit();
-    delete pMenu;
+    return std::unique_ptr<SalMenu>(pSalMenu);
 }
 
 std::unique_ptr<SalMenuItem> GtkInstance::CreateMenuItem( const SalItemParams & rItemData )
@@ -379,8 +373,7 @@ std::unique_ptr<SalMenuItem> GtkInstance::CreateMenuItem( const SalItemParams &
 
 #else // not ENABLE_GMENU_INTEGRATION
 
-SalMenu*     GtkInstance::CreateMenu( bool, Menu* )          { return nullptr; }
-void         GtkInstance::DestroyMenu( SalMenu* )                {}
+std::unique_ptr<SalMenu>     GtkInstance::CreateMenu( bool, Menu* )          { return nullptr; }
 std::unique_ptr<SalMenuItem> GtkInstance::CreateMenuItem( const SalItemParams & ) { return nullptr; }
 
 #endif
diff --git a/vcl/win/window/salmenu.cxx b/vcl/win/window/salmenu.cxx
index 56c8ca2ff92d..0b14967bdc61 100644
--- a/vcl/win/window/salmenu.cxx
+++ b/vcl/win/window/salmenu.cxx
@@ -43,7 +43,7 @@ bool SalData::IsKnownMenuHandle( HMENU hMenu )
 
 // WinSalInst factory methods
 
-SalMenu* WinSalInstance::CreateMenu( bool bMenuBar, Menu* )
+std::unique_ptr<SalMenu> WinSalInstance::CreateMenu( bool bMenuBar, Menu* )
 {
     WinSalMenu *pSalMenu = new WinSalMenu();
 
@@ -57,12 +57,7 @@ SalMenu* WinSalInstance::CreateMenu( bool bMenuBar, Menu* )
     if( pSalMenu->mhMenu )
         GetSalData()->mhMenuSet.insert( pSalMenu->mhMenu );
 
-    return pSalMenu;
-}
-
-void WinSalInstance::DestroyMenu( SalMenu* pSalMenu )
-{
-    delete pSalMenu;
+    return std::unique_ptr<SalMenu>(pSalMenu);
 }
 
 std::unique_ptr<SalMenuItem> WinSalInstance::CreateMenuItem( const SalItemParams & rItemData )


More information about the Libreoffice-commits mailing list