sfx2/source/notify/globalevents.cxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
New commits: commit 78485eb52d1f10a6ba0314370288f7e747e0ec53 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Sep 28 13:06:37 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Sep 28 15:11:40 2021 +0200 fix deadlock on exit regression from commit 8122c82d90117fc0c4c8ea87aa7f771d5e92bf36 osl::Mutex->std::mutex in SfxGlobalEvents_Imp Change-Id: Ifdde340a4cb6a84b5b396d04694e856f6bdd5c03 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122769 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sfx2/source/notify/globalevents.cxx b/sfx2/source/notify/globalevents.cxx index 3982fbecdb33..71fdd8a70aae 100644 --- a/sfx2/source/notify/globalevents.cxx +++ b/sfx2/source/notify/globalevents.cxx @@ -243,11 +243,17 @@ void SfxGlobalEvents_Impl::dispose() { std::multiset<css::uno::Reference<css::lang::XEventListener>> listeners; { std::unique_lock g(m_aLock); - m_xEvents.clear(); + if (m_disposed) + return; + m_disposed = true; + auto tmp = std::move(m_xEvents); m_xJobExecutorListener.clear(); m_disposeListeners.swap(listeners); m_lModels.clear(); - m_disposed = true; + g.unlock(); + // clear events outside lock because it will trigger a call back into us + tmp.clear(); + g.lock(); m_aLegacyListeners.disposeAndClear(g, {static_cast<OWeakObject *>(this)}); g.lock(); // because disposeAndClear is going to want to unlock() m_aDocumentListeners.disposeAndClear(g, {static_cast<OWeakObject *>(this)});