diff options
author | Noel Grandin <noel@peralex.com> | 2015-09-21 08:03:25 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2015-09-21 08:03:52 +0200 |
commit | 1e67e94f1a308ca60d4934e9fe9d5c048225ebe8 (patch) | |
tree | c3bdf0fcec6912bc84e835fe48a80ee9f9391106 /vcl/source | |
parent | c916152d8562cab868d4c522748ac30029fad179 (diff) |
convert Link<> to typed
Change-Id: If3e2b00092440ebd42ae5b73ae2b0e44c3702683
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/app/svapp.cxx | 8 | ||||
-rw-r--r-- | vcl/source/app/vclevent.cxx | 24 | ||||
-rw-r--r-- | vcl/source/control/tabctrl.cxx | 10 | ||||
-rw-r--r-- | vcl/source/window/event.cxx | 29 |
4 files changed, 42 insertions, 29 deletions
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index c57ca13d947e..b25b738b1c19 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -674,7 +674,7 @@ void Application::ImplCallEventListeners( sal_uLong nEvent, vcl::Window *pWin, v VclWindowEvent aEvent( pWin, nEvent, pData ); if ( pSVData->maAppData.mpEventListeners ) - pSVData->maAppData.mpEventListeners->Call( &aEvent ); + pSVData->maAppData.mpEventListeners->Call( aEvent ); } void Application::ImplCallEventListeners( VclSimpleEvent& rEvent ) @@ -682,10 +682,10 @@ void Application::ImplCallEventListeners( VclSimpleEvent& rEvent ) ImplSVData* pSVData = ImplGetSVData(); if ( pSVData->maAppData.mpEventListeners ) - pSVData->maAppData.mpEventListeners->Call( &rEvent ); + pSVData->maAppData.mpEventListeners->Call( rEvent ); } -void Application::AddEventListener( const Link<>& rEventListener ) +void Application::AddEventListener( const Link<VclSimpleEvent&,void>& rEventListener ) { ImplSVData* pSVData = ImplGetSVData(); if( !pSVData->maAppData.mpEventListeners ) @@ -693,7 +693,7 @@ void Application::AddEventListener( const Link<>& rEventListener ) pSVData->maAppData.mpEventListeners->addListener( rEventListener ); } -void Application::RemoveEventListener( const Link<>& rEventListener ) +void Application::RemoveEventListener( const Link<VclSimpleEvent&,void>& rEventListener ) { ImplSVData* pSVData = ImplGetSVData(); if( pSVData->maAppData.mpEventListeners ) diff --git a/vcl/source/app/vclevent.cxx b/vcl/source/app/vclevent.cxx index 6cc4523ba983..bcbe518f7b7b 100644 --- a/vcl/source/app/vclevent.cxx +++ b/vcl/source/app/vclevent.cxx @@ -43,25 +43,25 @@ VclAccessibleEvent::~VclAccessibleEvent() } -void VclEventListeners::Call( VclSimpleEvent* pEvent ) const +void VclEventListeners::Call( VclSimpleEvent& rEvent ) const { if ( m_aListeners.empty() ) return; // Copy the list, because this can be destroyed when calling a Link... - std::vector<Link<>> aCopy( m_aListeners ); - std::vector<Link<>>::iterator aIter( aCopy.begin() ); - std::vector<Link<>>::const_iterator aEnd( aCopy.end() ); - if( pEvent->IsA( VclWindowEvent::StaticType() ) ) + std::vector<Link<VclSimpleEvent&,void>> aCopy( m_aListeners ); + std::vector<Link<VclSimpleEvent&,void>>::iterator aIter( aCopy.begin() ); + std::vector<Link<VclSimpleEvent&,void>>::const_iterator aEnd( aCopy.end() ); + if( rEvent.IsA( VclWindowEvent::StaticType() ) ) { - VclWindowEvent* pWinEvent = static_cast<VclWindowEvent*>(pEvent); + VclWindowEvent* pWinEvent = static_cast<VclWindowEvent*>(&rEvent); ImplDelData aDel( pWinEvent->GetWindow() ); while ( aIter != aEnd && ! aDel.IsDead() ) { - Link<> &rLink = *aIter; + Link<VclSimpleEvent&,void> &rLink = *aIter; // check this hasn't been removed in some re-enterancy scenario fdo#47368 if( std::find(m_aListeners.begin(), m_aListeners.end(), rLink) != m_aListeners.end() ) - rLink.Call( pEvent ); + rLink.Call( rEvent ); ++aIter; } } @@ -69,20 +69,20 @@ void VclEventListeners::Call( VclSimpleEvent* pEvent ) const { while ( aIter != aEnd ) { - Link<> &rLink = *aIter; + Link<VclSimpleEvent&,void> &rLink = *aIter; if( std::find(m_aListeners.begin(), m_aListeners.end(), rLink) != m_aListeners.end() ) - rLink.Call( pEvent ); + rLink.Call( rEvent ); ++aIter; } } } -void VclEventListeners::addListener( const Link<>& rListener ) +void VclEventListeners::addListener( const Link<VclSimpleEvent&,void>& rListener ) { m_aListeners.push_back( rListener ); } -void VclEventListeners::removeListener( const Link<>& rListener ) +void VclEventListeners::removeListener( const Link<VclSimpleEvent&,void>& rListener ) { m_aListeners.erase( std::remove(m_aListeners.begin(), m_aListeners.end(), rListener ), m_aListeners.end() ); } diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index 2cda79ca6a34..a8f7a51a29d4 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -1008,19 +1008,17 @@ IMPL_LINK_NOARG(TabControl, ImplListBoxSelectHdl) return 0; } -IMPL_LINK( TabControl, ImplWindowEventListener, VclSimpleEvent*, pEvent ) +IMPL_LINK_TYPED( TabControl, ImplWindowEventListener, VclWindowEvent&, rEvent, void ) { - if ( pEvent && pEvent->ISA( VclWindowEvent ) && (pEvent->GetId() == VCLEVENT_WINDOW_KEYINPUT) ) + if ( rEvent.GetId() == VCLEVENT_WINDOW_KEYINPUT ) { - VclWindowEvent* pWindowEvent = static_cast< VclWindowEvent* >(pEvent); // Do not handle events from TabControl or its children, which is done in Notify(), where the events can be consumed. - if ( !IsWindowOrChild( pWindowEvent->GetWindow() ) ) + if ( !IsWindowOrChild( rEvent.GetWindow() ) ) { - KeyEvent* pKeyEvent = static_cast< KeyEvent* >(pWindowEvent->GetData()); + KeyEvent* pKeyEvent = static_cast< KeyEvent* >(rEvent.GetData()); ImplHandleKeyEvent( *pKeyEvent ); } } - return 0; } void TabControl::MouseButtonDown( const MouseEvent& rMEvt ) 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<Link<VclWindowEvent&,void>> aCopy( mpWindowImpl->maEventListeners ); + // Copy the list, because this can be destroyed when calling a Link... + std::vector<Link<VclWindowEvent&,void>> aCopy( mpWindowImpl->maEventListeners ); for ( Link<VclWindowEvent&,void>& 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<Link<VclWindowEvent&,void>> aCopy( mpWindowImpl->maChildEventListeners ); + for ( Link<VclWindowEvent&,void>& 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<VclWindowEvent&,void>& rEventListen } } -void Window::AddChildEventListener( const Link<>& rEventListener ) +void Window::AddChildEventListener( const Link<VclWindowEvent&,void>& rEventListener ) { - mpWindowImpl->maChildEventListeners.addListener( rEventListener ); + mpWindowImpl->maChildEventListeners.push_back( rEventListener ); } -void Window::RemoveChildEventListener( const Link<>& rEventListener ) +void Window::RemoveChildEventListener( const Link<VclWindowEvent&,void>& 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<void*,void>& rLink, void* pCaller, bool bReferenceLink ) |