sw/source/core/unocore/unoparagraph.cxx | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
New commits: commit 2ae53eb5dcbe0a3c5b4dc5323639a11878a38101 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Nov 1 10:05:17 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Nov 4 06:50:22 2022 +0100 tdf#126788 remove weak m_wThis reference weak references are surprsingly expensive in bulk. To make sure we don't get revive an object, we need to stop listening before we destroy the Impl object Change-Id: I8a3d99e29681e1f844598bc7ac792a659e1104f0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142092 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 7f8aa247260c..d2f3db46680e 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -114,7 +114,6 @@ class SwXParagraph::Impl { public: SwXParagraph& m_rThis; - unotools::WeakReference<SwXParagraph> m_wThis; std::mutex m_Mutex; // just for OInterfaceContainerHelper4 ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_EventListeners; SfxItemPropertySet const& m_rPropSet; @@ -192,12 +191,8 @@ void SwXParagraph::Impl::Notify(const SfxHint& rHint) std::unique_lock aGuard(m_Mutex); if (m_EventListeners.getLength(aGuard) != 0) { - uno::Reference<uno::XInterface> const xThis(m_wThis); - if (!xThis.is()) - { // fdo#72695: if UNO object is already dead, don't revive it with event - return; - } - lang::EventObject const ev(xThis); + uno::Reference<uno::XInterface> const xThis(m_rThis); + lang::EventObject const ev(m_rThis); m_EventListeners.disposeAndClear(aGuard, ev); } } @@ -219,6 +214,10 @@ SwXParagraph::SwXParagraph( SwXParagraph::~SwXParagraph() { + SolarMutexGuard aGuard; + // need to stop listening before destruction so we don't get DYING events + // that might then revive the SwXParagraph when constructing an EventObject + m_pImpl->EndListeningAll(); } const SwTextNode * SwXParagraph::GetTextNode() const @@ -265,8 +264,6 @@ SwXParagraph::CreateXParagraph(SwDoc & rDoc, SwTextNode *const pTextNode, { pTextNode->SetXParagraph(xParagraph); } - // need a permanent Reference to initialize m_wThis - pXPara->m_pImpl->m_wThis = xParagraph.get(); return xParagraph; }