summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/window/menu.cxx17
-rw-r--r--vcl/workben/vcldemo.cxx9
2 files changed, 10 insertions, 16 deletions
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index cd1b3fd9498c..fbc6ac1eb40a 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -578,8 +578,7 @@ void Menu::RemoveItem( sal_uInt16 nPos )
ImplCallEventListeners( VCLEVENT_MENU_REMOVEITEM, nPos );
}
-void ImplCopyItem( Menu* pThis, const Menu& rMenu, sal_uInt16 nPos, sal_uInt16 nNewPos,
- sal_uInt16 nMode = 0 )
+void ImplCopyItem( Menu* pThis, const Menu& rMenu, sal_uInt16 nPos, sal_uInt16 nNewPos )
{
MenuItemType eType = rMenu.GetItemType( nPos );
@@ -621,13 +620,8 @@ void ImplCopyItem( Menu* pThis, const Menu& rMenu, sal_uInt16 nPos, sal_uInt16 n
if ( pSubMenu )
{
// create auto-copy
- if ( nMode == 1 )
- {
- VclPtr<PopupMenu> pNewMenu = VclPtr<PopupMenu>::Create( *pSubMenu );
- pThis->SetPopupMenu( nId, pNewMenu );
- }
- else
- pThis->SetPopupMenu( nId, pSubMenu );
+ VclPtr<PopupMenu> pNewMenu = VclPtr<PopupMenu>::Create( *pSubMenu );
+ pThis->SetPopupMenu( nId, pNewMenu );
}
}
}
@@ -790,6 +784,9 @@ void Menu::SetPopupMenu( sal_uInt16 nItemId, PopupMenu* pMenu )
if ( static_cast<PopupMenu*>(pData->pSubMenu.get()) == pMenu )
return;
+ // remove old menu
+ pData->pSubMenu.disposeAndClear();
+
// data exchange
pData->pSubMenu = pMenu;
@@ -1203,7 +1200,7 @@ Menu& Menu::operator=( const Menu& rMenu )
// copy items
sal_uInt16 nCount = rMenu.GetItemCount();
for ( sal_uInt16 i = 0; i < nCount; i++ )
- ImplCopyItem( this, rMenu, i, MENU_APPEND, 1 );
+ ImplCopyItem( this, rMenu, i, MENU_APPEND );
nDefaultItem = rMenu.nDefaultItem;
aActivateHdl = rMenu.aActivateHdl;
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index e1b65851edcf..5458bb4799fd 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -1813,8 +1813,6 @@ public:
class DemoWidgets : public WorkWindow
{
VclPtr<MenuBar> mpBar;
- VclPtr<PopupMenu> mpPopup;
-
VclPtr<VclBox> mpBox;
VclPtr<ToolBox> mpToolbox;
VclPtr<PushButton> mpButton;
@@ -1869,9 +1867,9 @@ public:
mpBar = VclPtr<MenuBar>::Create();
mpBar->InsertItem(0,"File");
- mpPopup = VclPtr<PopupMenu>::Create();
- mpPopup->InsertItem(0,"Item");
- mpBar->SetPopupMenu(0, mpPopup);
+ VclPtrInstance<PopupMenu> pPopup;
+ pPopup->InsertItem(0,"Item");
+ mpBar->SetPopupMenu(0, pPopup);
SetMenuBar(mpBar);
Show();
@@ -1886,7 +1884,6 @@ public:
mpToolbox.disposeAndClear();
mpButton.disposeAndClear();
mpBox.disposeAndClear();
- mpPopup.disposeAndClear();
mpBar.disposeAndClear();
WorkWindow::dispose();
}