include/sfx2/tbxctrl.hxx | 12 ++++++------ linguistic/source/dlistimp.cxx | 38 ++++++++++++++++++-------------------- linguistic/source/dlistimp.hxx | 14 +++++--------- sfx2/source/toolbox/tbxitem.cxx | 10 ++-------- sfx2/source/view/viewsh.cxx | 19 ++++++++----------- 5 files changed, 39 insertions(+), 54 deletions(-)
New commits: commit 70b05273c91cfec0cd7a9a54ff993c5b7f808d4f Author: Noel Grandin <[email protected]> Date: Wed Jan 18 15:38:59 2017 +0200 use rtl::Reference in AsyncExecuteInfo instead of storing both a raw pointer and an uno::Reference Change-Id: Ia52aae8b3894813c4169772eb4cf89ae7df0003a diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 91e1c28..04e600f 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -124,12 +124,11 @@ public: struct AsyncExecuteInfo { - AsyncExecuteInfo( AsyncExecuteCmd eCmd, uno::Reference< datatransfer::clipboard::XClipboardListener > const & xThis, SfxClipboardChangeListener* pListener ) : - m_eCmd( eCmd ), m_xThis( xThis ), m_pListener( pListener ) {} + AsyncExecuteInfo( AsyncExecuteCmd eCmd, SfxClipboardChangeListener* pListener ) : + m_eCmd( eCmd ), m_xListener( pListener ) {} AsyncExecuteCmd m_eCmd; - uno::Reference< datatransfer::clipboard::XClipboardListener > m_xThis; - SfxClipboardChangeListener* m_pListener; + rtl::Reference<SfxClipboardChangeListener> m_xListener; }; private: @@ -173,13 +172,12 @@ IMPL_STATIC_LINK( SfxClipboardChangeListener, AsyncExecuteHdl_Impl, void*, p, vo AsyncExecuteInfo* pAsyncExecuteInfo = static_cast<AsyncExecuteInfo*>(p); if ( pAsyncExecuteInfo ) { - uno::Reference< datatransfer::clipboard::XClipboardListener > xThis( pAsyncExecuteInfo->m_xThis ); - if ( pAsyncExecuteInfo->m_pListener ) + if ( pAsyncExecuteInfo->m_xListener.is() ) { if ( pAsyncExecuteInfo->m_eCmd == ASYNCEXECUTE_CMD_DISPOSING ) - pAsyncExecuteInfo->m_pListener->DisconnectViewShell(); + pAsyncExecuteInfo->m_xListener->DisconnectViewShell(); else if ( pAsyncExecuteInfo->m_eCmd == ASYNCEXECUTE_CMD_CHANGEDCONTENTS ) - pAsyncExecuteInfo->m_pListener->ChangedContents(); + pAsyncExecuteInfo->m_xListener->ChangedContents(); } } delete pAsyncExecuteInfo; @@ -201,7 +199,7 @@ void SAL_CALL SfxClipboardChangeListener::disposing( const lang::EventObject& /* // Make asynchronous call to avoid locking SolarMutex which is the // root for many deadlocks, especially in conjunction with the "Windows" // based single thread apartment clipboard code! - AsyncExecuteInfo* pInfo = new AsyncExecuteInfo( ASYNCEXECUTE_CMD_DISPOSING, xThis, this ); + AsyncExecuteInfo* pInfo = new AsyncExecuteInfo( ASYNCEXECUTE_CMD_DISPOSING, this ); Application::PostUserEvent( LINK( nullptr, SfxClipboardChangeListener, AsyncExecuteHdl_Impl ), pInfo ); } @@ -211,8 +209,7 @@ void SAL_CALL SfxClipboardChangeListener::changedContents( const datatransfer::c // Make asynchronous call to avoid locking SolarMutex which is the // root for many deadlocks, especially in conjunction with the "Windows" // based single thread apartment clipboard code! - uno::Reference< datatransfer::clipboard::XClipboardListener > xThis( static_cast< datatransfer::clipboard::XClipboardListener* >( this )); - AsyncExecuteInfo* pInfo = new AsyncExecuteInfo( ASYNCEXECUTE_CMD_CHANGEDCONTENTS, xThis, this ); + AsyncExecuteInfo* pInfo = new AsyncExecuteInfo( ASYNCEXECUTE_CMD_CHANGEDCONTENTS, this ); Application::PostUserEvent( LINK( nullptr, SfxClipboardChangeListener, AsyncExecuteHdl_Impl ), pInfo ); } commit 5288ae5912d6c76cfb80a68025b3af4ba6045c6b Author: Noel Grandin <[email protected]> Date: Wed Jan 18 15:16:02 2017 +0200 use rtl::Reference in DicList instead of storing both a raw pointer and a uno::Reference Change-Id: I34bce1c6b3875fbb0dc56fefb79eb6b16f9818dd diff --git a/linguistic/source/dlistimp.cxx b/linguistic/source/dlistimp.cxx index f869630..19caeb9 100644 --- a/linguistic/source/dlistimp.cxx +++ b/linguistic/source/dlistimp.cxx @@ -269,19 +269,17 @@ void DicList::MyAppExitListener::AtExit() DicList::DicList() : aEvtListeners ( GetLinguMutex() ) { - pDicEvtLstnrHelper = new DicEvtListenerHelper( this ); - xDicEvtLstnrHelper = pDicEvtLstnrHelper; + mxDicEvtLstnrHelper = new DicEvtListenerHelper( this ); bDisposing = false; bInCreation = false; - pExitListener = new MyAppExitListener( *this ); - xExitListener = pExitListener; - pExitListener->Activate(); + mxExitListener = new MyAppExitListener( *this ); + mxExitListener->Activate(); } DicList::~DicList() { - pExitListener->Deactivate(); + mxExitListener->Deactivate(); } @@ -434,7 +432,7 @@ sal_Bool SAL_CALL DicList::addDictionary( bRes = true; // add listener helper to the dictionaries listener lists - xDictionary->addDictionaryEventListener( xDicEvtLstnrHelper ); + xDictionary->addDictionaryEventListener( mxDicEvtLstnrHelper.get() ); } return bRes; } @@ -461,7 +459,7 @@ sal_Bool SAL_CALL // deactivate dictionary if not already done xDic->setActive( false ); - xDic->removeDictionaryEventListener( xDicEvtLstnrHelper ); + xDic->removeDictionaryEventListener( mxDicEvtLstnrHelper.get() ); } // remove element at nPos @@ -486,7 +484,7 @@ sal_Bool SAL_CALL DicList::addDictionaryListEventListener( bool bRes = false; if (xListener.is()) //! don't add empty references { - bRes = pDicEvtLstnrHelper-> + bRes = mxDicEvtLstnrHelper-> AddDicListEvtListener( xListener, bReceiveVerbose ); } return bRes; @@ -504,7 +502,7 @@ sal_Bool SAL_CALL DicList::removeDictionaryListEventListener( bool bRes = false; if(xListener.is()) { - bRes = pDicEvtLstnrHelper->RemoveDicListEvtListener( xListener ); + bRes = mxDicEvtLstnrHelper->RemoveDicListEvtListener( xListener ); } return bRes; } @@ -512,19 +510,19 @@ sal_Bool SAL_CALL DicList::removeDictionaryListEventListener( sal_Int16 SAL_CALL DicList::beginCollectEvents() throw(RuntimeException, std::exception) { osl::MutexGuard aGuard( GetLinguMutex() ); - return pDicEvtLstnrHelper->BeginCollectEvents(); + return mxDicEvtLstnrHelper->BeginCollectEvents(); } sal_Int16 SAL_CALL DicList::endCollectEvents() throw(RuntimeException, std::exception) { osl::MutexGuard aGuard( GetLinguMutex() ); - return pDicEvtLstnrHelper->EndCollectEvents(); + return mxDicEvtLstnrHelper->EndCollectEvents(); } sal_Int16 SAL_CALL DicList::flushEvents() throw(RuntimeException, std::exception) { osl::MutexGuard aGuard( GetLinguMutex() ); - return pDicEvtLstnrHelper->FlushEvents(); + return mxDicEvtLstnrHelper->FlushEvents(); } uno::Reference< XDictionary > SAL_CALL @@ -563,8 +561,8 @@ void SAL_CALL EventObject aEvtObj( static_cast<XDictionaryList *>(this) ); aEvtListeners.disposeAndClear( aEvtObj ); - if (pDicEvtLstnrHelper) - pDicEvtLstnrHelper->DisposeAndClear( aEvtObj ); + if (mxDicEvtLstnrHelper.is()) + mxDicEvtLstnrHelper->DisposeAndClear( aEvtObj ); //! avoid creation of dictionaries if not already done if ( !aDicList.empty() ) @@ -592,10 +590,10 @@ void SAL_CALL // release references to (members of) this object hold by // dictionaries if (xDic.is()) - xDic->removeDictionaryEventListener( xDicEvtLstnrHelper ); + xDic->removeDictionaryEventListener( mxDicEvtLstnrHelper.get() ); } } - xDicEvtLstnrHelper.clear(); + mxDicEvtLstnrHelper.clear(); } } @@ -650,7 +648,7 @@ void DicList::CreateDicList() //! to suppress overwriting the list of active dictionaries in the //! configuration with incorrect arguments during the following //! activation of the dictionaries - pDicEvtLstnrHelper->BeginCollectEvents(); + mxDicEvtLstnrHelper->BeginCollectEvents(); const uno::Sequence< OUString > aActiveDics( aOpt.GetActiveDics() ); const OUString *pActiveDic = aActiveDics.getConstArray(); sal_Int32 nLen = aActiveDics.getLength(); @@ -666,9 +664,9 @@ void DicList::CreateDicList() // suppress collected events during creation of the dictionary list. // there should be no events during creation. - pDicEvtLstnrHelper->ClearEvents(); + mxDicEvtLstnrHelper->ClearEvents(); - pDicEvtLstnrHelper->EndCollectEvents(); + mxDicEvtLstnrHelper->EndCollectEvents(); bInCreation = false; } diff --git a/linguistic/source/dlistimp.hxx b/linguistic/source/dlistimp.hxx index 4d4062d..3e9130b 100644 --- a/linguistic/source/dlistimp.hxx +++ b/linguistic/source/dlistimp.hxx @@ -26,6 +26,7 @@ #include <cppuhelper/implbase.hxx> #include <cppuhelper/interfacecontainer.h> +#include <rtl/ref.hxx> #include <vector> @@ -54,18 +55,13 @@ class DicList : LinguOptions aOpt; - ::comphelper::OInterfaceContainerHelper2 aEvtListeners; + ::comphelper::OInterfaceContainerHelper2 aEvtListeners; typedef std::vector< css::uno::Reference< css::linguistic2::XDictionary > > DictionaryVec_t; - DictionaryVec_t aDicList; + DictionaryVec_t aDicList; - css::uno::Reference< css::linguistic2:: - XDictionaryEventListener > xDicEvtLstnrHelper; - DicEvtListenerHelper *pDicEvtLstnrHelper; - - css::uno::Reference< css::frame:: - XTerminateListener > xExitListener; - MyAppExitListener *pExitListener; + rtl::Reference<DicEvtListenerHelper> mxDicEvtLstnrHelper; + rtl::Reference<MyAppExitListener> mxExitListener; bool bDisposing; bool bInCreation; commit 73df118fde5ce5c380a5f9e8867240e2b5abfdcb Author: Noel Grandin <[email protected]> Date: Wed Jan 18 14:29:59 2017 +0200 use rtl::Reference in SfxPopupWindow instead of storing both a raw pointer and an uno::Reference Change-Id: I8fc679cd22f2ac24fb3f1c71939318921c1d674b diff --git a/include/sfx2/tbxctrl.hxx b/include/sfx2/tbxctrl.hxx index 96b45af..02783f4 100644 --- a/include/sfx2/tbxctrl.hxx +++ b/include/sfx2/tbxctrl.hxx @@ -35,6 +35,7 @@ #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/frame/XSubToolbarController.hpp> +#include <rtl/ref.hxx> class SfxToolBoxControl; @@ -67,13 +68,12 @@ class SfxFrameStatusListener; class SFX2_DLLPUBLIC SfxPopupWindow: public FloatingWindow { friend class SfxFrameStatusListener; - bool m_bFloating; - bool m_bCascading; - Link<SfxPopupWindow*,void> m_aDeleteLink; - sal_uInt16 m_nId; + bool m_bFloating; + bool m_bCascading; + Link<SfxPopupWindow*,void> m_aDeleteLink; + sal_uInt16 m_nId; css::uno::Reference< css::frame::XFrame > const m_xFrame; - SfxFrameStatusListener* m_pStatusListener; - css::uno::Reference< css::lang::XComponent > m_xStatusListener; + rtl::Reference<SfxFrameStatusListener> m_xStatusListener; private: SfxPopupWindow(SfxPopupWindow &) = delete; diff --git a/sfx2/source/toolbox/tbxitem.cxx b/sfx2/source/toolbox/tbxitem.cxx index 599a206..15df108 100644 --- a/sfx2/source/toolbox/tbxitem.cxx +++ b/sfx2/source/toolbox/tbxitem.cxx @@ -737,7 +737,6 @@ SfxPopupWindow::SfxPopupWindow( , m_bCascading( false ) , m_nId( nId ) , m_xFrame( rFrame ) - , m_pStatusListener( nullptr ) { vcl::Window* pWindow = GetTopMostParentSystemWindow( this ); if ( pWindow ) @@ -751,7 +750,6 @@ SfxPopupWindow::SfxPopupWindow(sal_uInt16 nId, const OString& rID, const OUStrin , m_bCascading( false ) , m_nId( nId ) , m_xFrame( rFrame ) - , m_pStatusListener( nullptr ) { vcl::Window* pWindow = GetTopMostParentSystemWindow( this ); if ( pWindow ) @@ -768,7 +766,6 @@ SfxPopupWindow::SfxPopupWindow( , m_bCascading( false ) , m_nId( nId ) , m_xFrame( rFrame ) - , m_pStatusListener( nullptr ) { vcl::Window* pWindow = GetTopMostParentSystemWindow( this ); if ( pWindow ) @@ -785,7 +782,6 @@ SfxPopupWindow::SfxPopupWindow( , m_bCascading( false ) , m_nId( nId ) , m_xFrame( rFrame ) - , m_pStatusListener( nullptr ) { vcl::Window* pWindow = GetTopMostParentSystemWindow( this ); if ( pWindow ) @@ -803,7 +799,6 @@ void SfxPopupWindow::dispose() { m_xStatusListener->dispose(); m_xStatusListener.clear(); - m_pStatusListener = nullptr; } vcl::Window* pWindow = GetTopMostParentSystemWindow( this ); @@ -817,14 +812,13 @@ void SfxPopupWindow::AddStatusListener( const OUString& rCommandURL ) { if ( !m_xStatusListener.is() ) { - m_pStatusListener = new SfxFrameStatusListener( + m_xStatusListener = new SfxFrameStatusListener( ::comphelper::getProcessComponentContext(), m_xFrame, this ); - m_xStatusListener.set( static_cast< cppu::OWeakObject* >( m_pStatusListener ), UNO_QUERY ); } if ( m_xStatusListener.is() ) - m_pStatusListener->addStatusListener( rCommandURL ); + m_xStatusListener->addStatusListener( rCommandURL ); } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
