tdf#126788 check for listeners first

cheaper than the WeakReference check

Change-Id: I2caaa80ed1f68c840758db2ad1fb97237606bbf1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142033
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2022-10-30 08:03:47 +02:00
parent 8c6467a785
commit b3329c10cc

View file

@ -3084,21 +3084,22 @@ void SwXTextTable::Impl::Notify(const SfxHint& rHint)
m_pFrameFormat = nullptr;
EndListeningAll();
}
std::unique_lock aGuard(m_Mutex);
if (m_EventListeners.getLength(aGuard) == 0 && m_ChartListeners.getLength(aGuard) == 0)
return;
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
if(!m_pFrameFormat)
{
lang::EventObject const ev(xThis);
std::unique_lock aGuard(m_Mutex);
m_EventListeners.disposeAndClear(aGuard, ev);
m_ChartListeners.disposeAndClear(aGuard, ev);
}
else
{
std::unique_lock aGuard(m_Mutex);
lcl_SendChartEvent(aGuard, xThis, m_ChartListeners);
}
// fdo#72695: if UNO object is already dead, don't revive it with event
if (!xThis)
return;
if(!m_pFrameFormat)
{
lang::EventObject const ev(xThis);
m_EventListeners.disposeAndClear(aGuard, ev);
m_ChartListeners.disposeAndClear(aGuard, ev);
}
else
{
lcl_SendChartEvent(aGuard, xThis, m_ChartListeners);
}
}