summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-09-18 09:39:28 +0200
committerNoel Grandin <noelgrandin@gmail.com>2015-09-20 06:35:47 +0000
commit81e1e318bb47d4dc2f479ac1809d355c117f8ce8 (patch)
tree0a5786ea6a1b9bb35438b7f9351ddad5e89d7b96 /vcl
parent75d339175e06334de42108c2e26adca65700608a (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>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/svdata.hxx7
-rw-r--r--vcl/source/app/svapp.cxx31
2 files changed, 31 insertions, 7 deletions
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()