diff options
author | Noel Grandin <noel@peralex.com> | 2015-09-18 09:39:28 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2015-09-20 06:35:47 +0000 |
commit | 81e1e318bb47d4dc2f479ac1809d355c117f8ce8 (patch) | |
tree | 0a5786ea6a1b9bb35438b7f9351ddad5e89d7b96 | |
parent | 75d339175e06334de42108c2e26adca65700608a (diff) |
convert Link<> to typed
Change-Id: If7fdd97d3c317a8e31641cc096c2c2639c1e012e
Reviewed-on: https://gerrit.libreoffice.org/18698
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
-rw-r--r-- | include/vcl/svapp.hxx | 4 | ||||
-rw-r--r-- | sd/source/ui/slideshow/slideshowimpl.cxx | 6 | ||||
-rw-r--r-- | sd/source/ui/slideshow/slideshowimpl.hxx | 8 | ||||
-rw-r--r-- | vcl/inc/svdata.hxx | 7 | ||||
-rw-r--r-- | vcl/source/app/svapp.cxx | 31 |
5 files changed, 40 insertions, 16 deletions
diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx index 06079c67d322..1365215afd5f 100644 --- a/include/vcl/svapp.hxx +++ b/include/vcl/svapp.hxx @@ -596,7 +596,7 @@ public: GetMainThreadIdentifier, ReleaseSolarMutex, AcquireSolarMutex, EnableNoYieldMode, DisableNoYieldMode, RemovePostYieldListener */ - static void AddPostYieldListener( const Link<>& i_rListener ); + static void AddPostYieldListener( const Link<LinkParamNone*,void>& i_rListener ); /** Remove listener for yield events @@ -606,7 +606,7 @@ public: GetMainThreadIdentifier, ReleaseSolarMutex, AcquireSolarMutex, AddPostYieldListener, EnableNoYieldMode, DisableNoYieldMode */ - static void RemovePostYieldListener( const Link<>& i_rListener ); + static void RemovePostYieldListener( const Link<LinkParamNone*,void>& i_rListener ); /** Queries whether the application is in "main", i.e. not yet in diff --git a/sd/source/ui/slideshow/slideshowimpl.cxx b/sd/source/ui/slideshow/slideshowimpl.cxx index d36cd09a2e6c..25a0a1f82a89 100644 --- a/sd/source/ui/slideshow/slideshowimpl.cxx +++ b/sd/source/ui/slideshow/slideshowimpl.cxx @@ -1788,7 +1788,7 @@ IMPL_LINK_NOARG_TYPED(SlideshowImpl, updateHdl, Timer *, void) updateSlideShow(); } -IMPL_LINK_NOARG(SlideshowImpl, PostYieldListener) +IMPL_LINK_NOARG_TYPED(SlideshowImpl, PostYieldListener, LinkParamNone*, void) { // prevent me from deletion when recursing (App::Reschedule does) const rtl::Reference<SlideshowImpl> this_(this); @@ -1799,9 +1799,9 @@ IMPL_LINK_NOARG(SlideshowImpl, PostYieldListener) // *all* outstanding events after // yield is done. if (mbDisposed) - return 0; + return; Application::Reschedule(true); - return updateSlideShow(); + updateSlideShow(); } sal_Int32 SlideshowImpl::updateSlideShow() diff --git a/sd/source/ui/slideshow/slideshowimpl.hxx b/sd/source/ui/slideshow/slideshowimpl.hxx index a7af2838e268..06ac09ef791a 100644 --- a/sd/source/ui/slideshow/slideshowimpl.hxx +++ b/sd/source/ui/slideshow/slideshowimpl.hxx @@ -274,13 +274,13 @@ private: void setActiveXToolbarsVisible( bool bVisible ); - DECL_LINK_TYPED(updateHdl, Timer *, void); - DECL_LINK( PostYieldListener, void* ); - DECL_LINK_TYPED(ReadyForNextInputHdl, Timer *, void); + DECL_LINK_TYPED( updateHdl, Timer *, void ); + DECL_LINK_TYPED( PostYieldListener, LinkParamNone*, void ); + DECL_LINK_TYPED( ReadyForNextInputHdl, Timer *, void ); DECL_LINK_TYPED( endPresentationHdl, void*, void ); DECL_LINK_TYPED( ContextMenuSelectHdl, Menu *, bool ); DECL_LINK_TYPED( ContextMenuHdl, void*, void ); - DECL_LINK_TYPED(deactivateHdl, Timer *, void); + DECL_LINK_TYPED( deactivateHdl, Timer *, void ); DECL_LINK( EventListenerHdl, VclSimpleEvent* ); // helper diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx index e7496aa71d24..91bd10fcffd4 100644 --- a/vcl/inc/svdata.hxx +++ b/vcl/inc/svdata.hxx @@ -104,6 +104,11 @@ public: typedef std::vector<Link<VclWindowEvent&,bool> > SVAppKeyListeners; +struct SVAppPostYieldListeners : public vcl::DeletionNotifier +{ + std::vector<Link<LinkParamNone*,void>> m_aListeners; +}; + struct ImplSVAppData { enum ImeStatusWindowMode @@ -128,7 +133,7 @@ struct ImplSVAppData VclPtr<ImplWheelWindow> mpWheelWindow; // WheelWindow ImplHotKey* mpFirstHotKey; // HotKey-Verwaltung ImplEventHook* mpFirstEventHook; // Event-Hooks - VclEventListeners2* mpPostYieldListeners; // post yield listeners + SVAppPostYieldListeners* mpPostYieldListeners; // post yield listeners sal_uInt64 mnLastInputTime; // GetLastInputTime() sal_uInt16 mnDispatchLevel; // DispatchLevel sal_uInt16 mnModalMode; // ModalMode Count diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index 2b5d8d789191..c57ca13d947e 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -377,7 +377,20 @@ inline void ImplYield(bool i_bWait, bool i_bAllEvents, sal_uLong const nReleased // call post yield listeners if( pSVData->maAppData.mpPostYieldListeners ) - pSVData->maAppData.mpPostYieldListeners->callListeners( NULL ); + { + vcl::DeletionListener aDel( pSVData->maAppData.mpPostYieldListeners ); + + auto& rYieldListeners = pSVData->maAppData.mpPostYieldListeners->m_aListeners; + // Copy the list, because this can be destroyed when calling a Link... + std::vector<Link<LinkParamNone*,void>> aCopy( rYieldListeners ); + for( Link<LinkParamNone*,void>& rLink : aCopy ) + { + if (aDel.isDeleted()) break; + // check this hasn't been removed in some re-enterancy scenario fdo#47368 + if( std::find(rYieldListeners.begin(), rYieldListeners.end(), rLink) != rYieldListeners.end() ) + rLink.Call( nullptr ); + } + } } void Application::Reschedule( bool i_bAllEvents ) @@ -960,19 +973,25 @@ void Application::DisableNoYieldMode() pSVData->maAppData.mbNoYield = false; } -void Application::AddPostYieldListener( const Link<>& i_rListener ) +void Application::AddPostYieldListener( const Link<LinkParamNone*,void>& i_rListener ) { ImplSVData* pSVData = ImplGetSVData(); if( ! pSVData->maAppData.mpPostYieldListeners ) - pSVData->maAppData.mpPostYieldListeners = new VclEventListeners2(); - pSVData->maAppData.mpPostYieldListeners->addListener( i_rListener ); + pSVData->maAppData.mpPostYieldListeners = new SVAppPostYieldListeners(); + // ensure uniqueness + auto& rYieldListeners = pSVData->maAppData.mpPostYieldListeners->m_aListeners; + if (std::find(rYieldListeners.begin(), rYieldListeners.end(), i_rListener) == rYieldListeners.end()) + rYieldListeners.push_back( i_rListener ); } -void Application::RemovePostYieldListener( const Link<>& i_rListener ) +void Application::RemovePostYieldListener( const Link<LinkParamNone*,void>& i_rListener ) { ImplSVData* pSVData = ImplGetSVData(); if( pSVData->maAppData.mpPostYieldListeners ) - pSVData->maAppData.mpPostYieldListeners->removeListener( i_rListener ); + { + auto& rYieldListeners = pSVData->maAppData.mpPostYieldListeners->m_aListeners; + rYieldListeners.erase( std::remove(rYieldListeners.begin(), rYieldListeners.end(), i_rListener ), rYieldListeners.end() ); + } } WorkWindow* Application::GetAppWindow() |