From 1e67e94f1a308ca60d4934e9fe9d5c048225ebe8 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 21 Sep 2015 08:03:25 +0200 Subject: convert Link<> to typed Change-Id: If3e2b00092440ebd42ae5b73ae2b0e44c3702683 --- vcl/source/window/event.cxx | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'vcl/source/window') diff --git a/vcl/source/window/event.cxx b/vcl/source/window/event.cxx index 20ee6164abbb..fbbf24532ac7 100644 --- a/vcl/source/window/event.cxx +++ b/vcl/source/window/event.cxx @@ -214,8 +214,8 @@ void Window::CallEventListeners( sal_uLong nEvent, void* pData ) if (!mpWindowImpl->maEventListeners.empty()) { - // Copy the list, because this can be destroyed when calling a Link... - std::vector> aCopy( mpWindowImpl->maEventListeners ); + // Copy the list, because this can be destroyed when calling a Link... + std::vector> aCopy( mpWindowImpl->maEventListeners ); for ( Link& rLink : aCopy ) { if (aDelData.IsDead()) break; @@ -238,7 +238,19 @@ void Window::CallEventListeners( sal_uLong nEvent, void* pData ) if ( aDelData.IsDead() ) return; - pWindow->mpWindowImpl->maChildEventListeners.Call( &aEvent ); + if (!mpWindowImpl->maEventListeners.empty()) + { + // Copy the list, because this can be destroyed when calling a Link... + std::vector> aCopy( mpWindowImpl->maChildEventListeners ); + for ( Link& rLink : aCopy ) + { + if (aDelData.IsDead()) + return; + // check this hasn't been removed in some re-enterancy scenario fdo#47368 + if( std::find(mpWindowImpl->maChildEventListeners.begin(), mpWindowImpl->maChildEventListeners.end(), rLink) != mpWindowImpl->maChildEventListeners.end() ) + rLink.Call( aEvent ); + } + } if ( aDelData.IsDead() ) return; @@ -268,15 +280,18 @@ void Window::RemoveEventListener( const Link& rEventListen } } -void Window::AddChildEventListener( const Link<>& rEventListener ) +void Window::AddChildEventListener( const Link& rEventListener ) { - mpWindowImpl->maChildEventListeners.addListener( rEventListener ); + mpWindowImpl->maChildEventListeners.push_back( rEventListener ); } -void Window::RemoveChildEventListener( const Link<>& rEventListener ) +void Window::RemoveChildEventListener( const Link& rEventListener ) { if (mpWindowImpl) - mpWindowImpl->maChildEventListeners.removeListener( rEventListener ); + { + auto& rListeners = mpWindowImpl->maChildEventListeners; + rListeners.erase( std::remove(rListeners.begin(), rListeners.end(), rEventListener ), rListeners.end() ); + } } ImplSVEvent * Window::PostUserEvent( const Link& rLink, void* pCaller, bool bReferenceLink ) -- cgit v1.2.3