summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-09-18 15:10:41 +0200
committerNoel Grandin <noelgrandin@gmail.com>2015-09-20 06:37:36 +0000
commit99bfc363a6f6779d0be2284f85a9131254bce1f9 (patch)
tree3da30adea892bae0f5e76031d8561e114c2da8d9 /vcl
parente3c3b7fde3c017bd7d25f04fabf9b4528e37fb49 (diff)
convert Link<> to typed
Change-Id: I10b050dc4aae45e646761a82520caa96969bc511 Reviewed-on: https://gerrit.libreoffice.org/18700 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/dndevdis.hxx2
-rw-r--r--vcl/inc/window.h2
-rw-r--r--vcl/source/window/dndevdis.cxx5
-rw-r--r--vcl/source/window/event.cxx24
-rw-r--r--vcl/source/window/layout.cxx5
-rw-r--r--vcl/source/window/menubarwindow.cxx22
-rw-r--r--vcl/source/window/menubarwindow.hxx6
-rw-r--r--vcl/source/window/menufloatingwindow.cxx9
-rw-r--r--vcl/source/window/menufloatingwindow.hxx8
9 files changed, 46 insertions, 37 deletions
diff --git a/vcl/inc/dndevdis.hxx b/vcl/inc/dndevdis.hxx
index 4d5df39aa3c0..915f83bcc7ca 100644
--- a/vcl/inc/dndevdis.hxx
+++ b/vcl/inc/dndevdis.hxx
@@ -36,7 +36,7 @@ class DNDEventDispatcher: public ::cppu::WeakImplHelper<
VclPtr<vcl::Window> m_pCurrentWindow;
void designate_currentwindow(vcl::Window *pWindow);
- DECL_LINK(WindowEventListener, VclSimpleEvent*);
+ DECL_LINK_TYPED(WindowEventListener, VclWindowEvent&, void);
::osl::Mutex m_aMutex;
::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > m_aDataFlavorList;
diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index 4745bf6a4372..00c1785067e7 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -229,7 +229,7 @@ public:
VclPtr<vcl::Window> mpNextOverlap;
VclPtr<vcl::Window> mpLastFocusWindow;
VclPtr<vcl::Window> mpDlgCtrlDownWindow;
- VclEventListeners maEventListeners;
+ std::vector<Link<VclWindowEvent&,void>> maEventListeners;
VclEventListeners maChildEventListeners;
// The canvas interface for this VCL window. Is persistent after the first GetCanvas() call
diff --git a/vcl/source/window/dndevdis.cxx b/vcl/source/window/dndevdis.cxx
index 94d6ae75b1dd..33dfbc44366c 100644
--- a/vcl/source/window/dndevdis.cxx
+++ b/vcl/source/window/dndevdis.cxx
@@ -70,13 +70,12 @@ vcl::Window* DNDEventDispatcher::findTopLevelWindow(Point location)
return pChildWindow;
}
-IMPL_LINK(DNDEventDispatcher, WindowEventListener, VclSimpleEvent*, pEvent)
+IMPL_LINK_TYPED(DNDEventDispatcher, WindowEventListener, VclWindowEvent&, rEvent, void)
{
- if (pEvent && pEvent->GetId() == VCLEVENT_OBJECT_DYING)
+ if (rEvent.GetId() == VCLEVENT_OBJECT_DYING)
{
designate_currentwindow(NULL);
}
- return 0;
}
void DNDEventDispatcher::designate_currentwindow(vcl::Window *pWindow)
diff --git a/vcl/source/window/event.cxx b/vcl/source/window/event.cxx
index 5bef68726978..20ee6164abbb 100644
--- a/vcl/source/window/event.cxx
+++ b/vcl/source/window/event.cxx
@@ -212,7 +212,18 @@ void Window::CallEventListeners( sal_uLong nEvent, void* pData )
if ( aDelData.IsDead() )
return;
- mpWindowImpl->maEventListeners.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->maEventListeners );
+ for ( Link<VclWindowEvent&,void>& rLink : aCopy )
+ {
+ if (aDelData.IsDead()) break;
+ // check this hasn't been removed in some re-enterancy scenario fdo#47368
+ if( std::find(mpWindowImpl->maEventListeners.begin(), mpWindowImpl->maEventListeners.end(), rLink) != mpWindowImpl->maEventListeners.end() )
+ rLink.Call( aEvent );
+ }
+ }
if ( aDelData.IsDead() )
return;
@@ -243,15 +254,18 @@ void Window::FireVclEvent( VclSimpleEvent& rEvent )
Application::ImplCallEventListeners(rEvent);
}
-void Window::AddEventListener( const Link<>& rEventListener )
+void Window::AddEventListener( const Link<VclWindowEvent&,void>& rEventListener )
{
- mpWindowImpl->maEventListeners.addListener( rEventListener );
+ mpWindowImpl->maEventListeners.push_back( rEventListener );
}
-void Window::RemoveEventListener( const Link<>& rEventListener )
+void Window::RemoveEventListener( const Link<VclWindowEvent&,void>& rEventListener )
{
if (mpWindowImpl)
- mpWindowImpl->maEventListeners.removeListener( rEventListener );
+ {
+ auto& rListeners = mpWindowImpl->maEventListeners;
+ rListeners.erase( std::remove(rListeners.begin(), rListeners.end(), rEventListener ), rListeners.end() );
+ }
}
void Window::AddChildEventListener( const Link<>& rEventListener )
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index 08692cce8ff1..532a6817a4c2 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -1351,11 +1351,10 @@ void VclFrame::setAllocation(const Size &rAllocation)
setLayoutAllocation(*pChild, aChildPos, aAllocation);
}
-IMPL_LINK(VclFrame, WindowEventListener, VclSimpleEvent*, pEvent)
+IMPL_LINK_TYPED(VclFrame, WindowEventListener, VclWindowEvent&, rEvent, void)
{
- if (pEvent && pEvent->GetId() == VCLEVENT_OBJECT_DYING)
+ if (rEvent.GetId() == VCLEVENT_OBJECT_DYING)
designate_label(NULL);
- return 0;
}
void VclFrame::designate_label(vcl::Window *pWindow)
diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx
index 5380b05af57c..ae6c6b83ae53 100644
--- a/vcl/source/window/menubarwindow.cxx
+++ b/vcl/source/window/menubarwindow.cxx
@@ -251,20 +251,20 @@ IMPL_LINK_NOARG_TYPED(MenuBarWindow, CloseHdl, ToolBox *, void)
}
}
-IMPL_LINK( MenuBarWindow, ToolboxEventHdl, VclWindowEvent*, pEvent )
+IMPL_LINK_TYPED( MenuBarWindow, ToolboxEventHdl, VclWindowEvent&, rEvent, void )
{
if( ! pMenu )
- return 0;
+ return;
MenuBar::MenuBarButtonCallbackArg aArg;
aArg.nId = 0xffff;
- aArg.bHighlight = (pEvent->GetId() == VCLEVENT_TOOLBOX_HIGHLIGHT);
+ aArg.bHighlight = (rEvent.GetId() == VCLEVENT_TOOLBOX_HIGHLIGHT);
aArg.pMenuBar = dynamic_cast<MenuBar*>(pMenu);
- if( pEvent->GetId() == VCLEVENT_TOOLBOX_HIGHLIGHT )
+ if( rEvent.GetId() == VCLEVENT_TOOLBOX_HIGHLIGHT )
aArg.nId = aCloseBtn->GetHighlightItemId();
- else if( pEvent->GetId() == VCLEVENT_TOOLBOX_HIGHLIGHTOFF )
+ else if( rEvent.GetId() == VCLEVENT_TOOLBOX_HIGHLIGHTOFF )
{
- sal_uInt16 nPos = static_cast< sal_uInt16 >(reinterpret_cast<sal_IntPtr>(pEvent->GetData()));
+ sal_uInt16 nPos = static_cast< sal_uInt16 >(reinterpret_cast<sal_IntPtr>(rEvent.GetData()));
aArg.nId = aCloseBtn->GetItemId(nPos);
}
std::map< sal_uInt16, AddButtonEntry >::iterator it = m_aAddButtons.find( aArg.nId );
@@ -272,19 +272,17 @@ IMPL_LINK( MenuBarWindow, ToolboxEventHdl, VclWindowEvent*, pEvent )
{
it->second.m_aHighlightLink.Call( aArg );
}
- return 0;
}
-IMPL_LINK( MenuBarWindow, ShowHideListener, VclWindowEvent*, pEvent )
+IMPL_LINK_TYPED( MenuBarWindow, ShowHideListener, VclWindowEvent&, rEvent, void )
{
if( ! pMenu )
- return 0;
+ return;
- if( pEvent->GetId() == VCLEVENT_WINDOW_SHOW )
+ if( rEvent.GetId() == VCLEVENT_WINDOW_SHOW )
pMenu->ImplCallEventListeners( VCLEVENT_MENU_SHOW, ITEMPOS_INVALID );
- else if( pEvent->GetId() == VCLEVENT_WINDOW_HIDE )
+ else if( rEvent.GetId() == VCLEVENT_WINDOW_HIDE )
pMenu->ImplCallEventListeners( VCLEVENT_MENU_HIDE, ITEMPOS_INVALID );
- return 0;
}
void MenuBarWindow::ImplCreatePopup( bool bPreSelectFirst )
diff --git a/vcl/source/window/menubarwindow.hxx b/vcl/source/window/menubarwindow.hxx
index f460a770f45c..7621faf92898 100644
--- a/vcl/source/window/menubarwindow.hxx
+++ b/vcl/source/window/menubarwindow.hxx
@@ -103,9 +103,9 @@ private:
virtual void ApplySettings(vcl::RenderContext& rRenderContext) SAL_OVERRIDE;
- DECL_LINK_TYPED(CloseHdl, ToolBox*, void);
- DECL_LINK( ToolboxEventHdl, VclWindowEvent* );
- DECL_LINK( ShowHideListener, VclWindowEvent* );
+ DECL_LINK_TYPED( CloseHdl, ToolBox*, void );
+ DECL_LINK_TYPED( ToolboxEventHdl, VclWindowEvent&, void );
+ DECL_LINK_TYPED( ShowHideListener, VclWindowEvent&, void );
void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx
index 33d33e0ad324..1a2fb4c50351 100644
--- a/vcl/source/window/menufloatingwindow.cxx
+++ b/vcl/source/window/menufloatingwindow.cxx
@@ -363,16 +363,15 @@ IMPL_LINK_NOARG_TYPED(MenuFloatingWindow, SubmenuClose, Timer *, void)
}
}
-IMPL_LINK( MenuFloatingWindow, ShowHideListener, VclWindowEvent*, pEvent )
+IMPL_LINK_TYPED( MenuFloatingWindow, ShowHideListener, VclWindowEvent&, rEvent, void )
{
if( ! pMenu )
- return 0;
+ return;
- if( pEvent->GetId() == VCLEVENT_WINDOW_SHOW )
+ if( rEvent.GetId() == VCLEVENT_WINDOW_SHOW )
pMenu->ImplCallEventListeners( VCLEVENT_MENU_SHOW, ITEMPOS_INVALID );
- else if( pEvent->GetId() == VCLEVENT_WINDOW_HIDE )
+ else if( rEvent.GetId() == VCLEVENT_WINDOW_HIDE )
pMenu->ImplCallEventListeners( VCLEVENT_MENU_HIDE, ITEMPOS_INVALID );
- return 0;
}
void MenuFloatingWindow::EnableScrollMenu( bool b )
diff --git a/vcl/source/window/menufloatingwindow.hxx b/vcl/source/window/menufloatingwindow.hxx
index 60a688bad775..2b555aaefc7a 100644
--- a/vcl/source/window/menufloatingwindow.hxx
+++ b/vcl/source/window/menufloatingwindow.hxx
@@ -57,11 +57,11 @@ private:
bool bIgnoreFirstMove : 1;
bool bKeyInput : 1;
- DECL_LINK_TYPED(PopupEnd, FloatingWindow*, void);
+ DECL_LINK_TYPED( PopupEnd, FloatingWindow*, void );
DECL_LINK_TYPED( HighlightChanged, Timer*, void );
- DECL_LINK_TYPED(SubmenuClose, Timer *, void);
- DECL_LINK_TYPED(AutoScroll, Timer *, void);
- DECL_LINK( ShowHideListener, VclWindowEvent* );
+ DECL_LINK_TYPED( SubmenuClose, Timer *, void );
+ DECL_LINK_TYPED( AutoScroll, Timer *, void );
+ DECL_LINK_TYPED( ShowHideListener, VclWindowEvent&, void );
virtual void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;