pass unique_lock as param in WeakComponentImplHelperBase::disposing

so that subclasses can drop the lock while calling listeners

Change-Id: I6105438110af08f10b0ed50057b28172c3442b95
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127434
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2021-12-24 15:58:17 +02:00
committed by Noel Grandin
parent f0c0c62c10
commit c68c744b68
10 changed files with 18 additions and 13 deletions

View File

@@ -120,7 +120,7 @@ namespace accessibility
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override;
// XComponent/WeakComponentImplHelper
virtual void disposing() override;
virtual void disposing(std::unique_lock<std::mutex>&) override;
EditBrowseBoxTableCellAccess( const EditBrowseBoxTableCellAccess& ) = delete;
EditBrowseBoxTableCellAccess& operator=( const EditBrowseBoxTableCellAccess& ) = delete;

View File

@@ -212,7 +212,7 @@ namespace accessibility
return xMyContext;
}
void EditBrowseBoxTableCellAccess::disposing()
void EditBrowseBoxTableCellAccess::disposing(std::unique_lock<std::mutex>&)
{
// dispose our context, if it still alive
css::uno::Reference< XComponent > xMyContext( m_aContext.get(), UNO_QUERY );

View File

@@ -90,7 +90,7 @@ namespace canvas
const css::uno::Sequence< css::uno::Any >& rArgs );
/// Dispose all internal references
virtual void disposing() override;
virtual void disposing(std::unique_lock<std::mutex>&) override;
// XParametricPolyPolygon2D
virtual css::uno::Reference< css::rendering::XPolyPolygon2D > SAL_CALL getOutline( double t ) override;

View File

@@ -147,7 +147,7 @@ namespace canvas
colors, stops, fAspectRatio );
}
void ParametricPolyPolygon::disposing()
void ParametricPolyPolygon::disposing(std::unique_lock<std::mutex>&)
{
mxDevice.clear();
}

View File

@@ -25,12 +25,14 @@ void SAL_CALL WeakComponentImplHelperBase::dispose()
if (m_bDisposed)
return;
m_bDisposed = true;
disposing();
disposing(aGuard);
if (!aGuard.owns_lock())
aGuard.lock();
css::lang::EventObject aEvt(static_cast<OWeakObject*>(this));
maEventListeners.disposeAndClear(aGuard, aEvt);
}
void WeakComponentImplHelperBase::disposing() {}
void WeakComponentImplHelperBase::disposing(std::unique_lock<std::mutex>&) {}
void SAL_CALL WeakComponentImplHelperBase::addEventListener(
css::uno::Reference<css::lang::XEventListener> const& rxListener)

View File

@@ -41,8 +41,11 @@ public:
virtual void SAL_CALL
removeEventListener(css::uno::Reference<css::lang::XEventListener> const& rxListener) override;
/** called by dispose for subclasses to do dispose() work */
virtual void disposing();
/**
Called by dispose for subclasses to do dispose() work.
The mutex is held when called, and subclasses can unlock() the guard if necessary.
*/
virtual void disposing(std::unique_lock<std::mutex>&);
protected:
comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> maEventListeners;

View File

@@ -690,7 +690,7 @@ void ChildrenManagerImpl::impl_dispose()
}
void ChildrenManagerImpl::disposing()
void ChildrenManagerImpl::disposing(std::unique_lock<std::mutex>&)
{
impl_dispose();
}

View File

@@ -315,7 +315,7 @@ private:
/** This method is called from the component helper base class while
disposing.
*/
virtual void disposing() override;
virtual void disposing(std::unique_lock<std::mutex>&) override;
void impl_dispose();

View File

@@ -391,7 +391,7 @@ void SAL_CALL TableDesignStyle::replaceByName( const OUString& rName, const Any&
// XComponent
void SAL_CALL TableDesignStyle::disposing()
void TableDesignStyle::disposing()
{
for(Reference<XStyle> & rCellStyle : maCellStyles)
rCellStyle.clear();

View File

@@ -947,7 +947,7 @@ public:
protected:
// is called from WeakComponentImplHelper when XComponent::dispose() was
// called from outside
virtual void disposing() override;
virtual void disposing(std::unique_lock<std::mutex>&) override;
// ____ XInitialization ____
// one argument is allowed, which is the XStorage
@@ -993,7 +993,7 @@ SvXMLGraphicImportExportHelper::SvXMLGraphicImportExportHelper( SvXMLGraphicHelp
m_eGraphicHelperMode( eMode )
{}
void SvXMLGraphicImportExportHelper::disposing()
void SvXMLGraphicImportExportHelper::disposing(std::unique_lock<std::mutex>&)
{
Reference< XComponent > xComp( m_xGraphicObjectResolver, UNO_QUERY );
OSL_ASSERT( xComp.is());