diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-02-21 10:02:50 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-02-21 10:39:38 +0000 |
commit | c2c22a8ca6e04779c4daada73003b03c963b4cfd (patch) | |
tree | 06ff97be57be43698896ac12585871ab4371b04c /svx | |
parent | d56b6e0904c276e9a9ea63eb226e6324422c21c8 (diff) |
osl::Mutex->std::mutex in FmXGridPeer
Change-Id: Ib0796a86f864ab0a1a1b99183668f486a8a8f198
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147381
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/fmcomp/fmgridif.cxx | 69 |
1 files changed, 41 insertions, 28 deletions
diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx index 05ccd00c75c9..f78f6bb2100f 100644 --- a/svx/source/fmcomp/fmgridif.cxx +++ b/svx/source/fmcomp/fmgridif.cxx @@ -1020,26 +1020,23 @@ void FmXGridPeer::GridListenerDelegator::columnChanged() void FmXGridPeer::selectionChanged() { + std::unique_lock g(m_aMutex); EventObject aSource; aSource.Source = static_cast< ::cppu::OWeakObject* >(this); - m_aSelectionListeners.notifyEach( &XSelectionChangeListener::selectionChanged, aSource); + m_aSelectionListeners.notifyEach( g, &XSelectionChangeListener::selectionChanged, aSource); } void FmXGridPeer::columnChanged() { + std::unique_lock g(m_aMutex); EventObject aEvent( *this ); - m_aGridControlListeners.notifyEach( &XGridControlListener::columnChanged, aEvent ); + m_aGridControlListeners.notifyEach( g, &XGridControlListener::columnChanged, aEvent ); } FmXGridPeer::FmXGridPeer(const Reference< XComponentContext >& _rxContext) :m_xContext(_rxContext) - ,m_aModifyListeners(m_aMutex) - ,m_aUpdateListeners(m_aMutex) - ,m_aContainerListeners(m_aMutex) - ,m_aSelectionListeners(m_aMutex) - ,m_aGridControlListeners(m_aMutex) ,m_aMode("DataMode") ,m_nCursorListening(0) ,m_bInterceptingDispatch(false) @@ -1124,13 +1121,15 @@ void FmXGridPeer::disposing(const EventObject& e) void FmXGridPeer::addModifyListener(const Reference< css::util::XModifyListener >& l) { - m_aModifyListeners.addInterface( l ); + std::unique_lock g(m_aMutex); + m_aModifyListeners.addInterface( g, l ); } void FmXGridPeer::removeModifyListener(const Reference< css::util::XModifyListener >& l) { - m_aModifyListeners.removeInterface( l ); + std::unique_lock g(m_aMutex); + m_aModifyListeners.removeInterface( g, l ); } @@ -1312,9 +1311,10 @@ Sequence< Any > SAL_CALL FmXGridPeer::queryFieldData( sal_Int32 nRow, const Type void FmXGridPeer::CellModified() { + std::unique_lock g(m_aMutex); EventObject aEvt; aEvt.Source = static_cast< ::cppu::OWeakObject* >(this); - m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvt ); + m_aModifyListeners.notifyEach( g, &XModifyListener::modified, aEvt ); } // XPropertyChangeListener @@ -1433,13 +1433,15 @@ void FmXGridPeer::propertyChange(const PropertyChangeEvent& evt) void FmXGridPeer::addUpdateListener(const Reference< XUpdateListener >& l) { - m_aUpdateListeners.addInterface(l); + std::unique_lock g(m_aMutex); + m_aUpdateListeners.addInterface(g, l); } void FmXGridPeer::removeUpdateListener(const Reference< XUpdateListener >& l) { - m_aUpdateListeners.removeInterface(l); + std::unique_lock g(m_aMutex); + m_aUpdateListeners.removeInterface(g, l); } @@ -1449,8 +1451,9 @@ sal_Bool FmXGridPeer::commit() if (!m_xCursor.is() || !pGrid) return true; + std::unique_lock g(m_aMutex); EventObject aEvt(static_cast< ::cppu::OWeakObject* >(this)); - ::comphelper::OInterfaceIteratorHelper3 aIter(m_aUpdateListeners); + ::comphelper::OInterfaceIteratorHelper4 aIter(g, m_aUpdateListeners); bool bCancel = false; while (aIter.hasMoreElements() && !bCancel) if ( !aIter.next()->approveUpdate( aEvt ) ) @@ -1460,7 +1463,7 @@ sal_Bool FmXGridPeer::commit() bCancel = !pGrid->commit(); if (!bCancel) - m_aUpdateListeners.notifyEach( &XUpdateListener::updated, aEvt ); + m_aUpdateListeners.notifyEach( g, &XUpdateListener::updated, aEvt ); return !bCancel; } @@ -2036,12 +2039,14 @@ Any FmXGridPeer::getProperty( const OUString& _rPropertyName ) void FmXGridPeer::dispose() { - EventObject aEvt; - aEvt.Source = static_cast< ::cppu::OWeakObject* >(this); - m_aModifyListeners.disposeAndClear(aEvt); - m_aUpdateListeners.disposeAndClear(aEvt); - m_aContainerListeners.disposeAndClear(aEvt); - + { + std::unique_lock g(m_aMutex); + EventObject aEvt; + aEvt.Source = static_cast< ::cppu::OWeakObject* >(this); + m_aModifyListeners.disposeAndClear(g, aEvt); + m_aUpdateListeners.disposeAndClear(g, aEvt); + m_aContainerListeners.disposeAndClear(g, aEvt); + } // release all interceptors Reference< XDispatchProviderInterceptor > xInterceptor( m_xFirstDispatchInterceptor ); m_xFirstDispatchInterceptor.clear(); @@ -2095,12 +2100,14 @@ void FmXGridPeer::dispose() void FmXGridPeer::addContainerListener(const Reference< XContainerListener >& l) { - m_aContainerListeners.addInterface( l ); + std::unique_lock g(m_aMutex); + m_aContainerListeners.addInterface( g, l ); } void FmXGridPeer::removeContainerListener(const Reference< XContainerListener >& l) { - m_aContainerListeners.removeInterface( l ); + std::unique_lock g(m_aMutex); + m_aContainerListeners.removeInterface( g, l ); } // css::data::XDatabaseCursorSupplier @@ -2202,13 +2209,15 @@ void FmXGridPeer::setRowSet(const Reference< XRowSet >& _rDatabaseCursor) void SAL_CALL FmXGridPeer::addGridControlListener( const Reference< XGridControlListener >& _listener ) { - m_aGridControlListeners.addInterface( _listener ); + std::unique_lock g(m_aMutex); + m_aGridControlListeners.addInterface( g, _listener ); } void SAL_CALL FmXGridPeer::removeGridControlListener( const Reference< XGridControlListener >& _listener ) { - m_aGridControlListeners.removeInterface( _listener ); + std::unique_lock g(m_aMutex); + m_aGridControlListeners.removeInterface( g, _listener ); } @@ -2387,7 +2396,8 @@ void FmXGridPeer::columnVisible(DbGridColumn const * pColumn) aEvt.Accessor <<= _nIndex; aEvt.Element <<= xControl; - m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, aEvt ); + std::unique_lock g(m_aMutex); + m_aContainerListeners.notifyEach( g, &XContainerListener::elementInserted, aEvt ); } @@ -2402,7 +2412,8 @@ void FmXGridPeer::columnHidden(DbGridColumn const * pColumn) aEvt.Accessor <<= _nIndex; aEvt.Element <<= xControl; - m_aContainerListeners.notifyEach( &XContainerListener::elementRemoved, aEvt ); + std::unique_lock g(m_aMutex); + m_aContainerListeners.notifyEach( g, &XContainerListener::elementRemoved, aEvt ); } @@ -2586,13 +2597,15 @@ Any SAL_CALL FmXGridPeer::getSelection( ) void SAL_CALL FmXGridPeer::addSelectionChangeListener( const Reference< XSelectionChangeListener >& _rxListener ) { - m_aSelectionListeners.addInterface( _rxListener ); + std::unique_lock g(m_aMutex); + m_aSelectionListeners.addInterface( g, _rxListener ); } void SAL_CALL FmXGridPeer::removeSelectionChangeListener( const Reference< XSelectionChangeListener >& _rxListener ) { - m_aSelectionListeners.removeInterface( _rxListener ); + std::unique_lock g(m_aMutex); + m_aSelectionListeners.removeInterface( g, _rxListener ); } |