summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-09-28 13:06:37 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-09-28 15:11:40 +0200
commit78485eb52d1f10a6ba0314370288f7e747e0ec53 (patch)
tree06cff91d17487ac44cbb4dabf6fdcb4b8411335a
parent6552ec19d1920a0c4ab074b4a16afc0fe39296f3 (diff)
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.grandin@collabora.co.uk>
-rw-r--r--sfx2/source/notify/globalevents.cxx10
1 files changed, 8 insertions, 2 deletions
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)});