diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-03-18 09:31:28 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-03-18 09:43:18 +0100 |
commit | c63f42e26ac61ef776fc7aa125d695f742358dc4 (patch) | |
tree | 39ce949cd59c1eb7289967c04ffc833b06e1a678 /framework | |
parent | 8ca1c57f0449c951515c3c3b448d0acda56b26fb (diff) |
Use SolarMutexGuard directly
Change-Id: Ieb26a4b63bc93254c54b18c209514aee55186407
Diffstat (limited to 'framework')
-rw-r--r-- | framework/inc/dispatch/menudispatcher.hxx | 11 | ||||
-rw-r--r-- | framework/source/dispatch/menudispatcher.cxx | 27 |
2 files changed, 11 insertions, 27 deletions
diff --git a/framework/inc/dispatch/menudispatcher.hxx b/framework/inc/dispatch/menudispatcher.hxx index 9cb73ae48aef..588ecd402b1c 100644 --- a/framework/inc/dispatch/menudispatcher.hxx +++ b/framework/inc/dispatch/menudispatcher.hxx @@ -24,7 +24,6 @@ #include <macros/generic.hxx> #include <macros/xinterface.hxx> #include <macros/xtypeprovider.hxx> -#include <threadhelp/threadhelpbase.hxx> #include <classes/menumanager.hxx> #include <general.h> #include <stdtypes.h> @@ -67,16 +66,11 @@ typedef ::cppu::OMultiTypeInterfaceContainerHelperVar< OUString , XLoadEventListener XFrameActionListener XEventListener - @base ThreadHelpBase - OWeakObject + @base OWeakObject @devstatus ready to use *//*-*************************************************************************************************************/ -class MenuDispatcher : // baseclasses - // Order is necessary for right initialization! - public ThreadHelpBase , - // interfaces - public ::cppu::WeakImplHelper2< +class MenuDispatcher : public ::cppu::WeakImplHelper2< css::frame::XDispatch , css::frame::XFrameActionListener > { @@ -250,6 +244,7 @@ class MenuDispatcher : // baseclasses css::uno::WeakReference< css::frame::XFrame > m_xOwnerWeak ; /// css::uno::WeakReference to owner (Don't use a hard css::uno::Reference. Owner can't delete us then!) css::uno::Reference< css::uno::XComponentContext > m_xContext ; /// factory shared with our owner to create new services! + osl::Mutex m_mutex; IMPL_ListenerHashContainer m_aListenerContainer; /// hash table for listener at specified URLs sal_Bool m_bAlreadyDisposed ; /// Protection against multiple disposing calls. sal_Bool m_bActivateListener ; /// dispatcher is listener for frame activation diff --git a/framework/source/dispatch/menudispatcher.cxx b/framework/source/dispatch/menudispatcher.cxx index a775af308d1e..85b1c6c53c3e 100644 --- a/framework/source/dispatch/menudispatcher.cxx +++ b/framework/source/dispatch/menudispatcher.cxx @@ -21,7 +21,6 @@ #include <general.h> #include <framework/menuconfiguration.hxx> #include <framework/addonmenu.hxx> -#include <threadhelp/guard.hxx> #include <services.h> #include <com/sun/star/frame/FrameSearchFlag.hpp> @@ -70,12 +69,9 @@ static sal_Bool impldbg_checkParameter_removeStatusListener ( const css::uno MenuDispatcher::MenuDispatcher( const uno::Reference< XComponentContext >& xContext , const uno::Reference< XFrame >& xOwner ) - // Init baseclasses first - : ThreadHelpBase ( &Application::GetSolarMutex() ) - // Init member - , m_xOwnerWeak ( xOwner ) + : m_xOwnerWeak ( xOwner ) , m_xContext ( xContext ) - , m_aListenerContainer ( m_aLock.getShareableOslMutex() ) + , m_aListenerContainer ( m_mutex ) , m_bAlreadyDisposed ( sal_False ) , m_bActivateListener ( sal_False ) , m_pMenuManager ( NULL ) @@ -112,8 +108,7 @@ void SAL_CALL MenuDispatcher::dispatch( const URL& / void SAL_CALL MenuDispatcher::addStatusListener( const uno::Reference< XStatusListener >& xControl, const URL& aURL ) throw( RuntimeException, std::exception ) { - // Ready for multithreading - Guard aGuard( m_aLock ); + SolarMutexGuard g; // Safe impossible cases // Method not defined for all incoming parameter SAL_WARN_IF( !impldbg_checkParameter_addStatusListener( xControl, aURL ), "fwk", "MenuDispatcher::addStatusListener(): Invalid parameter detected." ); @@ -127,8 +122,7 @@ void SAL_CALL MenuDispatcher::addStatusListener( const uno::Reference< XStat void SAL_CALL MenuDispatcher::removeStatusListener( const uno::Reference< XStatusListener >& xControl, const URL& aURL ) throw( RuntimeException, std::exception ) { - // Ready for multithreading - Guard aGuard( m_aLock ); + SolarMutexGuard g; // Safe impossible cases // Method not defined for all incoming parameter SAL_WARN_IF( !impldbg_checkParameter_removeStatusListener( xControl, aURL ), "fwk", "MenuDispatcher::removeStatusListener(): Invalid parameter detected." ); @@ -142,19 +136,19 @@ void SAL_CALL MenuDispatcher::removeStatusListener( const uno::Reference< X void SAL_CALL MenuDispatcher::frameAction( const FrameActionEvent& aEvent ) throw ( RuntimeException, std::exception ) { - Guard aGuard( m_aLock ); + SolarMutexResettableGuard aGuard; if ( m_pMenuManager && aEvent.Action == FrameAction_FRAME_UI_ACTIVATED ) { MenuBar* pMenuBar = (MenuBar *)m_pMenuManager->GetMenu(); uno::Reference< XFrame > xFrame( m_xOwnerWeak.get(), UNO_QUERY ); - aGuard.unlock(); + aGuard.clear(); if ( xFrame.is() && pMenuBar ) { uno::Reference< ::com::sun::star::awt::XWindow >xContainerWindow = xFrame->getContainerWindow(); - SolarMutexGuard aSolarGuard; + aGuard.reset(); { Window* pWindow = VCLUnoHelper::GetWindow( xContainerWindow ); while ( pWindow && !pWindow->IsSystemWindow() ) @@ -179,8 +173,7 @@ void SAL_CALL MenuDispatcher::frameAction( const FrameActionEvent& aEvent ) thro // XEventListener void SAL_CALL MenuDispatcher::disposing( const EventObject& ) throw( RuntimeException, std::exception ) { - // Ready for multithreading - Guard aGuard( m_aLock ); + SolarMutexGuard g; // Safe impossible cases SAL_WARN_IF( m_bAlreadyDisposed, "fwk", "MenuDispatcher::disposing(): Object already disposed .. don't call it again!" ); @@ -244,7 +237,6 @@ sal_Bool MenuDispatcher::impl_setMenuBar( MenuBar* pMenuBar, sal_Bool bMenuFromR uno::Reference< ::com::sun::star::awt::XWindow >xContainerWindow = xFrame->getContainerWindow(); Window* pWindow = NULL; - // Use SolarMutex for threadsafe code too! SolarMutexGuard aSolarGuard; { pWindow = VCLUnoHelper::GetWindow( xContainerWindow ); @@ -254,9 +246,6 @@ sal_Bool MenuDispatcher::impl_setMenuBar( MenuBar* pMenuBar, sal_Bool bMenuFromR if ( pWindow ) { - // Ready for multithreading - Guard aGuard( m_aLock ); - SystemWindow* pSysWindow = (SystemWindow *)pWindow; if ( m_pMenuManager ) |