diff options
author | Noel Grandin <noel@peralex.com> | 2015-09-10 16:44:12 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2015-09-11 08:48:55 +0200 |
commit | 71a83295d8c719f4fd4fa05f367c3c85323e22e9 (patch) | |
tree | 1ff99c92e49ad61e7b478daad338fd6109324222 /vcl/source/window | |
parent | c80fb09256f02379b78f7bb219e94dfbf5277872 (diff) |
convert Link<> to typed
and remove unused maChildEventListeners
Change-Id: I845a9af608c3429cf9ccb0e8041f24f423839513
Diffstat (limited to 'vcl/source/window')
-rw-r--r-- | vcl/source/window/menu.cxx | 28 | ||||
-rw-r--r-- | vcl/source/window/toolbox2.cxx | 7 |
2 files changed, 16 insertions, 19 deletions
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index c2e415a4ede2..98d9740bedab 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -340,31 +340,29 @@ void Menu::ImplCallEventListeners( sal_uLong nEvent, sal_uInt16 nPos ) } if ( !aDelData.isDeleted() ) - maEventListeners.Call( &aEvent ); - - if( !aDelData.isDeleted() ) { - Menu* pMenu = this; - while ( pMenu ) + // Copy the list, because this can be destroyed when calling a Link... + std::list<Link<VclMenuEvent&,void>> aCopy( maEventListeners ); + std::list<Link<VclMenuEvent&,void>>::iterator aIter( aCopy.begin() ); + std::list<Link<VclMenuEvent&,void>>::const_iterator aEnd( aCopy.end() ); + while ( aIter != aEnd ) { - maChildEventListeners.Call( &aEvent ); - - if( aDelData.isDeleted() ) - break; - - pMenu = ( pMenu->pStartedFrom != pMenu ) ? pMenu->pStartedFrom : NULL; + Link<VclMenuEvent&,void> &rLink = *aIter; + if( std::find(maEventListeners.begin(), maEventListeners.end(), rLink) != maEventListeners.end() ) + rLink.Call( aEvent ); + ++aIter; } } } -void Menu::AddEventListener( const Link<>& rEventListener ) +void Menu::AddEventListener( const Link<VclMenuEvent&,void>& rEventListener ) { - maEventListeners.addListener( rEventListener ); + maEventListeners.push_back( rEventListener ); } -void Menu::RemoveEventListener( const Link<>& rEventListener ) +void Menu::RemoveEventListener( const Link<VclMenuEvent&,void>& rEventListener ) { - maEventListeners.removeListener( rEventListener ); + maEventListeners.remove( rEventListener ); } MenuItemData* Menu::NbcInsertItem(sal_uInt16 nId, MenuItemBits nBits, diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx index 9c2af02d1c0d..6b570f92a551 100644 --- a/vcl/source/window/toolbox2.cxx +++ b/vcl/source/window/toolbox2.cxx @@ -1851,15 +1851,14 @@ void ToolBox::UpdateCustomMenu() } } -IMPL_LINK( ToolBox, ImplCustomMenuListener, VclMenuEvent*, pEvent ) +IMPL_LINK_TYPED( ToolBox, ImplCustomMenuListener, VclMenuEvent&, rEvent, void ) { - if( pEvent->GetMenu() == GetMenu() && pEvent->GetId() == VCLEVENT_MENU_SELECT ) + if( rEvent.GetMenu() == GetMenu() && rEvent.GetId() == VCLEVENT_MENU_SELECT ) { - sal_uInt16 id = GetMenu()->GetItemId( pEvent->GetItemPos() ); + sal_uInt16 id = GetMenu()->GetItemId( rEvent.GetItemPos() ); if( id >= TOOLBOX_MENUITEM_START ) TriggerItem( id - TOOLBOX_MENUITEM_START, false ); } - return 0; } IMPL_LINK_NOARG_TYPED(ToolBox, ImplCallExecuteCustomMenu, void*, void) |