From 9cef1d069a21cb821b1ef880da0358aa2a959a40 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 12 Sep 2023 13:32:21 +0200 Subject: loplugin:unodispose in UnoControls Change-Id: Id3cc80804b982cec04e288d0709c5d402e69860d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156841 Tested-by: Jenkins Reviewed-by: Noel Grandin --- UnoControls/source/controls/framecontrol.cxx | 46 ++++++++++--------------- UnoControls/source/controls/statusindicator.cxx | 2 ++ 2 files changed, 21 insertions(+), 27 deletions(-) (limited to 'UnoControls/source/controls') diff --git a/UnoControls/source/controls/framecontrol.cxx b/UnoControls/source/controls/framecontrol.cxx index 87dd4a07f6f9..f58c77a3b76a 100644 --- a/UnoControls/source/controls/framecontrol.cxx +++ b/UnoControls/source/controls/framecontrol.cxx @@ -175,7 +175,25 @@ Reference< XControlModel > SAL_CALL FrameControl::getModel() void SAL_CALL FrameControl::dispose() { - impl_deleteFrame(); + Reference< XFrame2 > xOldFrame; + { + // do not dispose the frame in this guarded section (deadlock?) + MutexGuard aGuard( m_aMutex ); + xOldFrame = std::move(m_xFrame); + } + + // notify the listeners + sal_Int32 nFrameId = PropertyHandle::Frame; + Reference< XFrame2 > xNullFrame; + Any aNewFrame( &xNullFrame, cppu::UnoType::get()); + Any aOldFrame( &xOldFrame, cppu::UnoType::get()); + fire( &nFrameId, &aNewFrame, &aOldFrame, 1, false ); + + // dispose the frame + if( xOldFrame.is() ) + xOldFrame->dispose(); + + m_aConnectionPointContainer.clear(); BaseControl::dispose(); } @@ -402,32 +420,6 @@ void FrameControl::impl_createFrame( const Reference< XWindowPeer >& xPee } } -// private method - -void FrameControl::impl_deleteFrame() -{ - Reference< XFrame2 > xOldFrame; - Reference< XFrame2 > xNullFrame; - - { - // do not dispose the frame in this guarded section (deadlock?) - MutexGuard aGuard( m_aMutex ); - xOldFrame = m_xFrame; - m_xFrame.clear(); - } - - // notify the listeners - sal_Int32 nFrameId = PropertyHandle::Frame; - Any aNewFrame( &xNullFrame, cppu::UnoType::get()); - Any aOldFrame( &xOldFrame, cppu::UnoType::get()); - fire( &nFrameId, &aNewFrame, &aOldFrame, 1, false ); - - // dispose the frame - if( xOldFrame.is() ) - xOldFrame->dispose(); -} - - } // namespace unocontrols extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* diff --git a/UnoControls/source/controls/statusindicator.cxx b/UnoControls/source/controls/statusindicator.cxx index 448b193d9a61..d35b5f99b191 100644 --- a/UnoControls/source/controls/statusindicator.cxx +++ b/UnoControls/source/controls/statusindicator.cxx @@ -288,6 +288,8 @@ void SAL_CALL StatusIndicator::dispose () // when other hold a reference at this object !!! xTextControl->dispose(); m_xProgressBar->dispose(); + m_xProgressBar.clear(); + m_xText.clear(); BaseContainerControl::dispose(); } -- cgit