[Libreoffice-commits] core.git: cui/source dbaccess/source include/svx include/vcl svtools/source svx/source sw/source vcl/source

Maxim Monastirsky momonasmon at gmail.com
Thu Oct 27 22:11:30 UTC 2016


 cui/source/tabpages/numpages.cxx       |    4 ----
 cui/source/tabpages/tpline.cxx         |   12 ------------
 dbaccess/source/ui/browser/sbagrid.cxx |    2 +-
 dbaccess/source/ui/inc/sbagrid.hxx     |    2 +-
 include/svx/fmgridcl.hxx               |    2 +-
 include/vcl/menu.hxx                   |    1 -
 svtools/source/contnr/svimpbox.cxx     |   15 ---------------
 svx/source/fmcomp/fmgridcl.cxx         |    5 +----
 sw/source/uibase/inc/workctrl.hxx      |    3 ---
 sw/source/uibase/ribbar/workctrl.cxx   |   20 ++------------------
 vcl/source/window/menu.cxx             |    7 -------
 11 files changed, 6 insertions(+), 67 deletions(-)

New commits:
commit 89c23b4aaef931b5d6009efaf44ce6e6c976e8d4
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date:   Thu Oct 27 22:31:47 2016 +0300

    Sub menus no longer need manual disposing
    
    after:
    
    commit ee79a2dd7ea60e902cab3a9203e307b8a78fee23
    Author: Caolán McNamara <caolanm at redhat.com>
    Date:   Fri Jul 29 14:33:22 2016 +0100
    
        Resolves: tdf#101169 crash using column menu in base
    
    Change-Id: I7c6e54dd5574c61cffd5884d1cf1b63075073001
    Reviewed-on: https://gerrit.libreoffice.org/30343
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Maxim Monastirsky <momonasmon at gmail.com>

diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx
index fc2719c..5846d9e 100644
--- a/cui/source/tabpages/numpages.cxx
+++ b/cui/source/tabpages/numpages.cxx
@@ -1188,10 +1188,6 @@ SvxNumOptionsTabPage::~SvxNumOptionsTabPage()
 
 void SvxNumOptionsTabPage::dispose()
 {
-    if (m_pBitmapMB)
-    {
-        m_pBitmapMB->GetPopupMenu()->DisposePopupMenu(m_nGalleryId);
-    }
     delete pActNum;
     pActNum = nullptr;
     delete pSaveNum;
diff --git a/cui/source/tabpages/tpline.cxx b/cui/source/tabpages/tpline.cxx
index 43f51a5..11ffd61 100644
--- a/cui/source/tabpages/tpline.cxx
+++ b/cui/source/tabpages/tpline.cxx
@@ -227,18 +227,6 @@ SvxLineTabPage::~SvxLineTabPage()
 
 void SvxLineTabPage::dispose()
 {
-    // Symbols on a line (e.g. StarCharts), dtor new!
-    if (m_pSymbolMB)
-    {
-        m_pSymbolMB->GetPopupMenu()->DisposePopupMenu( MN_GALLERY );
-
-        if(m_pSymbolList)
-        {
-            m_pSymbolMB->GetPopupMenu()->DisposePopupMenu( MN_SYMBOLS );
-        }
-        m_pSymbolMB = nullptr;
-    }
-
     for (SvxBmpItemInfo* pInfo : m_aGrfBrushItems)
     {
         delete pInfo->pBrushItem;
diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx
index 983ab27..374a3bb 100644
--- a/dbaccess/source/ui/browser/sbagrid.cxx
+++ b/dbaccess/source/ui/browser/sbagrid.cxx
@@ -681,7 +681,7 @@ void SbaGridHeader::PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rM
     }
 }
 
-void SbaGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu, sal_uInt16 nExecutionResult)
+void SbaGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMenu& rMenu, sal_uInt16 nExecutionResult)
 {
     switch (nExecutionResult)
     {
diff --git a/dbaccess/source/ui/inc/sbagrid.hxx b/dbaccess/source/ui/inc/sbagrid.hxx
index 18e20d5..4908ab9 100644
--- a/dbaccess/source/ui/inc/sbagrid.hxx
+++ b/dbaccess/source/ui/inc/sbagrid.hxx
@@ -176,7 +176,7 @@ namespace dbaui
 
         // FmGridHeader overridables
         virtual void    PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu) override;
-        virtual void    PostExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu, sal_uInt16 nExecutionResult) override;
+        virtual void    PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMenu& rMenu, sal_uInt16 nExecutionResult) override;
 
     private:
         // DragSourceHelper overridables
diff --git a/include/svx/fmgridcl.hxx b/include/svx/fmgridcl.hxx
index f2e114c..78ad042 100644
--- a/include/svx/fmgridcl.hxx
+++ b/include/svx/fmgridcl.hxx
@@ -67,7 +67,7 @@ protected:
     virtual void    PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu);
     /** After executing the context menu for a column this method is called.
     */
-    virtual void    PostExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu, sal_uInt16 nExecutionResult);
+    virtual void    PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMenu& rMenu, sal_uInt16 nExecutionResult);
 
     // DropTargetHelper
     virtual sal_Int8    AcceptDrop( const AcceptDropEvent& rEvt ) override;
diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx
index 684c2a8..959d54d 100644
--- a/include/vcl/menu.hxx
+++ b/include/vcl/menu.hxx
@@ -282,7 +282,6 @@ public:
 
     void SetPopupMenu( sal_uInt16 nItemId, PopupMenu* pMenu );
     PopupMenu* GetPopupMenu( sal_uInt16 nItemId ) const;
-    void DisposePopupMenu( sal_uInt16 nItemId );
 
     void SetAccelKey( sal_uInt16 nItemId, const vcl::KeyCode& rKeyCode );
     vcl::KeyCode GetAccelKey( sal_uInt16 nItemId ) const;
diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx
index 6cd671b..b535552 100644
--- a/svtools/source/contnr/svimpbox.cxx
+++ b/svtools/source/contnr/svimpbox.cxx
@@ -2912,20 +2912,6 @@ void SvImpLBox::PaintDDCursor( SvTreeListEntry* pInsertionPos )
     pView->SetRasterOp( eOldOp );
 }
 
-// Delete all submenus of a PopupMenu, recursively
-static void lcl_DeleteSubPopups(PopupMenu* pPopup)
-{
-    for(sal_uInt16 i = 0; i < pPopup->GetItemCount(); i++)
-    {
-        VclPtr<PopupMenu> pSubPopup = pPopup->GetPopupMenu( pPopup->GetItemId( i ));
-        if(pSubPopup)
-        {
-            lcl_DeleteSubPopups(pSubPopup);
-            pPopup->DisposePopupMenu( pPopup->GetItemId( i ));
-        }
-    }
-}
-
 void SvImpLBox::Command( const CommandEvent& rCEvt )
 {
     CommandEventId   nCommand = rCEvt.GetCommand();
@@ -3024,7 +3010,6 @@ void SvImpLBox::Command( const CommandEvent& rCEvt )
                 sal_uInt16 nMenuAction = pPopup->Execute( pView, aPopupPos );
                 if ( nMenuAction )
                     pView->ExecuteContextMenuAction( nMenuAction );
-                lcl_DeleteSubPopups(pPopup.get());
                 pPopup.disposeAndClear();
             }
         }
diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx
index 27994a3..130dd4f 100644
--- a/svx/source/fmcomp/fmgridcl.cxx
+++ b/svx/source/fmcomp/fmgridcl.cxx
@@ -775,14 +775,11 @@ void FmGridHeader::PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMe
 
 enum InspectorAction { eOpenInspector, eCloseInspector, eUpdateInspector, eNone };
 
-void FmGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu, sal_uInt16 nExecutionResult)
+void FmGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMenu& rMenu, sal_uInt16 nExecutionResult)
 {
     Reference< css::container::XIndexContainer >  xCols(static_cast<FmGridControl*>(GetParent())->GetPeer()->getColumns());
     sal_uInt16 nPos = GetModelColumnPos(nColId);
 
-    // remove and delete the menu we inserted in PreExecuteColumnContextMenu
-    rMenu.DisposePopupMenu(SID_FM_CHANGECOL);
-
     OUString aFieldType;
     bool    bReplace = false;
     InspectorAction eInspectorAction = eNone;
diff --git a/sw/source/uibase/inc/workctrl.hxx b/sw/source/uibase/inc/workctrl.hxx
index 3133b69..ba259bf 100644
--- a/sw/source/uibase/inc/workctrl.hxx
+++ b/sw/source/uibase/inc/workctrl.hxx
@@ -53,9 +53,6 @@ class SwView;
 
 class SwTbxAutoTextCtrl : public SfxToolBoxControl
 {
-    VclPtr<PopupMenu>       pPopup;
-
-    void                    DelPopup();
 public:
     SFX_DECL_TOOLBOX_CONTROL();
 
diff --git a/sw/source/uibase/ribbar/workctrl.cxx b/sw/source/uibase/ribbar/workctrl.cxx
index 32eb4c5..8007a50 100644
--- a/sw/source/uibase/ribbar/workctrl.cxx
+++ b/sw/source/uibase/ribbar/workctrl.cxx
@@ -67,26 +67,24 @@ SwTbxAutoTextCtrl::SwTbxAutoTextCtrl(
     sal_uInt16 nSlotId,
     sal_uInt16 nId,
     ToolBox& rTbx ) :
-    SfxToolBoxControl( nSlotId, nId, rTbx ),
-    pPopup(nullptr)
+    SfxToolBoxControl( nSlotId, nId, rTbx )
 {
     rTbx.SetItemBits( nId, ToolBoxItemBits::DROPDOWN | rTbx.GetItemBits( nId ) );
 }
 
 SwTbxAutoTextCtrl::~SwTbxAutoTextCtrl()
 {
-    DelPopup();
 }
 
 VclPtr<SfxPopupWindow> SwTbxAutoTextCtrl::CreatePopupWindow()
 {
+    ScopedVclPtrInstance<PopupMenu> pPopup;
     SwView* pView = ::GetActiveView();
     if(pView && !pView->GetDocShell()->IsReadOnly() &&
        !pView->GetWrtShell().HasReadonlySel() )
     {
         Link<Menu*,bool> aLnk = LINK(this, SwTbxAutoTextCtrl, PopupHdl);
 
-        pPopup = VclPtr<PopupMenu>::Create();
         SwGlossaryList* pGlossaryList = ::GetGlossaryList();
         const size_t nGroupCount = pGlossaryList->GetGroupCount();
         for(size_t i = 1; i <= nGroupCount; ++i)
@@ -123,9 +121,7 @@ VclPtr<SfxPopupWindow> SwTbxAutoTextCtrl::CreatePopupWindow()
         pToolBox->SetItemDown( nId, false );
     }
     GetToolBox().EndSelection();
-    DelPopup();
     return nullptr;
-
 }
 
 void SwTbxAutoTextCtrl::StateChanged( sal_uInt16,
@@ -158,18 +154,6 @@ IMPL_STATIC_LINK(SwTbxAutoTextCtrl, PopupHdl, Menu*, pMenu, bool)
     return false;
 }
 
-void SwTbxAutoTextCtrl::DelPopup()
-{
-    if(pPopup)
-    {
-        for( sal_uInt16 i = 0; i < pPopup->GetItemCount(); i ++ )
-        {
-            pPopup->DisposePopupMenu(pPopup->GetItemId(i));
-        }
-        pPopup.disposeAndClear();
-    }
-}
-
 // Navigation-Popup
 // determine the order of the toolbox items
 static sal_uInt16 aNavigationInsertIds[ NAVI_ENTRIES ] =
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 7af1ad3..743d724 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -819,13 +819,6 @@ PopupMenu* Menu::GetPopupMenu( sal_uInt16 nItemId ) const
         return nullptr;
 }
 
-void Menu::DisposePopupMenu( sal_uInt16 nItemId )
-{
-    MenuItemData* pData = pItemList->GetData( nItemId );
-    if ( pData )
-        pData->pSubMenu.disposeAndClear();
-}
-
 void Menu::SetAccelKey( sal_uInt16 nItemId, const KeyCode& rKeyCode )
 {
     size_t          nPos;


More information about the Libreoffice-commits mailing list