Kaydet (Commit) 31052b36 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Use SolarMutexGuard directly

Change-Id: I2ae1a43862754030f88df033551c93fdbeeab14a
üst c63f42e2
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include <macros/xinterface.hxx> #include <macros/xinterface.hxx>
#include <macros/xtypeprovider.hxx> #include <macros/xtypeprovider.hxx>
#include <macros/xserviceinfo.hxx> #include <macros/xserviceinfo.hxx>
#include <threadhelp/threadhelpbase.hxx>
#include <general.h> #include <general.h>
#include <stdtypes.h> #include <stdtypes.h>
...@@ -69,16 +68,11 @@ typedef ::cppu::OMultiTypeInterfaceContainerHelperVar< OUString , ...@@ -69,16 +68,11 @@ typedef ::cppu::OMultiTypeInterfaceContainerHelperVar< OUString ,
XLoadEventListener XLoadEventListener
XFrameActionListener XFrameActionListener
XEventListener XEventListener
@base ThreadHelpBase @base OWeakObject
OWeakObject
@devstatus ready to use @devstatus ready to use
*//*-*************************************************************************************************************/ *//*-*************************************************************************************************************/
class PopupMenuDispatcher : // baseclasses class PopupMenuDispatcher : public ::cppu::WeakImplHelper5<
// Order is necessary for right initialization!
public ThreadHelpBase ,
// interfaces
public ::cppu::WeakImplHelper5<
css::lang::XServiceInfo, css::lang::XServiceInfo,
css::frame::XDispatchProvider, css::frame::XDispatchProvider,
css::frame::XDispatch, css::frame::XDispatch,
...@@ -142,6 +136,7 @@ class PopupMenuDispatcher : // baseclasses ...@@ -142,6 +136,7 @@ class PopupMenuDispatcher : // baseclasses
css::uno::Reference< css::container::XNameAccess > m_xPopupCtrlQuery ; /// reference to query for popup controller css::uno::Reference< css::container::XNameAccess > m_xPopupCtrlQuery ; /// reference to query for popup controller
css::uno::Reference< css::uri::XUriReferenceFactory > m_xUriRefFactory ; /// reference to the uri reference factory css::uno::Reference< css::uri::XUriReferenceFactory > m_xUriRefFactory ; /// reference to the uri reference factory
css::uno::Reference< css::uno::XComponentContext > m_xContext ; /// factory shared with our owner to create new services! 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 IMPL_ListenerHashContainer m_aListenerContainer; /// hash table for listener at specified URLs
sal_Bool m_bAlreadyDisposed ; /// Protection against multiple disposing calls. sal_Bool m_bAlreadyDisposed ; /// Protection against multiple disposing calls.
sal_Bool m_bActivateListener ; /// dispatcher is listener for frame activation sal_Bool m_bActivateListener ; /// dispatcher is listener for frame activation
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include <general.h> #include <general.h>
#include <framework/menuconfiguration.hxx> #include <framework/menuconfiguration.hxx>
#include <framework/addonmenu.hxx> #include <framework/addonmenu.hxx>
#include <threadhelp/guard.hxx>
#include <services.h> #include <services.h>
#include <properties.h> #include <properties.h>
...@@ -60,11 +59,8 @@ using namespace ::rtl ; ...@@ -60,11 +59,8 @@ using namespace ::rtl ;
PopupMenuDispatcher::PopupMenuDispatcher( PopupMenuDispatcher::PopupMenuDispatcher(
const uno::Reference< XComponentContext >& xContext ) const uno::Reference< XComponentContext >& xContext )
// Init baseclasses first : m_xContext ( xContext )
: ThreadHelpBase ( &Application::GetSolarMutex() ) , m_aListenerContainer ( m_mutex )
// Init member
, m_xContext ( xContext )
, m_aListenerContainer ( m_aLock.getShareableOslMutex() )
, m_bAlreadyDisposed ( sal_False ) , m_bAlreadyDisposed ( sal_False )
, m_bActivateListener ( sal_False ) , m_bActivateListener ( sal_False )
{ {
...@@ -147,9 +143,7 @@ throw( css::uno::Exception, css::uno::RuntimeException, std::exception) ...@@ -147,9 +143,7 @@ throw( css::uno::Exception, css::uno::RuntimeException, std::exception)
{ {
css::uno::Reference< css::frame::XFrame > xFrame; css::uno::Reference< css::frame::XFrame > xFrame;
/* SAFE { */ SolarMutexGuard g;
Guard aWriteLock(m_aLock);
for (int a=0; a<lArguments.getLength(); ++a) for (int a=0; a<lArguments.getLength(); ++a)
{ {
if (a==0) if (a==0)
...@@ -163,9 +157,6 @@ throw( css::uno::Exception, css::uno::RuntimeException, std::exception) ...@@ -163,9 +157,6 @@ throw( css::uno::Exception, css::uno::RuntimeException, std::exception)
xFrame->addFrameActionListener( xFrameActionListener ); xFrame->addFrameActionListener( xFrameActionListener );
} }
} }
aWriteLock.unlock();
/* } SAFE */
} }
css::uno::Reference< css::frame::XDispatch > css::uno::Reference< css::frame::XDispatch >
...@@ -180,13 +171,13 @@ throw( css::uno::RuntimeException, std::exception ) ...@@ -180,13 +171,13 @@ throw( css::uno::RuntimeException, std::exception )
if ( rURL.Complete.startsWith( "vnd.sun.star.popup:" ) ) if ( rURL.Complete.startsWith( "vnd.sun.star.popup:" ) )
{ {
// --- SAFE --- // --- SAFE ---
Guard aGuard( m_aLock ); SolarMutexClearableGuard aGuard;
impl_RetrievePopupControllerQuery(); impl_RetrievePopupControllerQuery();
impl_CreateUriRefFactory(); impl_CreateUriRefFactory();
css::uno::Reference< css::container::XNameAccess > xPopupCtrlQuery( m_xPopupCtrlQuery ); css::uno::Reference< css::container::XNameAccess > xPopupCtrlQuery( m_xPopupCtrlQuery );
css::uno::Reference< css::uri::XUriReferenceFactory > xUriRefFactory( m_xUriRefFactory ); css::uno::Reference< css::uri::XUriReferenceFactory > xUriRefFactory( m_xUriRefFactory );
aGuard.unlock(); aGuard.clear();
// --- SAFE --- // --- SAFE ---
if ( xPopupCtrlQuery.is() ) if ( xPopupCtrlQuery.is() )
...@@ -214,7 +205,7 @@ throw( css::uno::RuntimeException, std::exception ) ...@@ -214,7 +205,7 @@ throw( css::uno::RuntimeException, std::exception )
// Find popup menu controller using the base URL // Find popup menu controller using the base URL
xPopupCtrlQuery->getByName( aBaseURL ) >>= xDispatchProvider; xPopupCtrlQuery->getByName( aBaseURL ) >>= xDispatchProvider;
aGuard.unlock(); aGuard.clear();
// Ask popup menu dispatch provider for dispatch object // Ask popup menu dispatch provider for dispatch object
if ( xDispatchProvider.is() ) if ( xDispatchProvider.is() )
...@@ -258,8 +249,7 @@ void SAL_CALL PopupMenuDispatcher::addStatusListener( const uno::Reference< XSta ...@@ -258,8 +249,7 @@ void SAL_CALL PopupMenuDispatcher::addStatusListener( const uno::Reference< XSta
const URL& aURL ) const URL& aURL )
throw( RuntimeException, std::exception ) throw( RuntimeException, std::exception )
{ {
// Ready for multithreading SolarMutexGuard g;
Guard aGuard( m_aLock );
// Safe impossible cases // Safe impossible cases
// Add listener to container. // Add listener to container.
m_aListenerContainer.addInterface( aURL.Complete, xControl ); m_aListenerContainer.addInterface( aURL.Complete, xControl );
...@@ -269,8 +259,7 @@ void SAL_CALL PopupMenuDispatcher::removeStatusListener( const uno::Reference< X ...@@ -269,8 +259,7 @@ void SAL_CALL PopupMenuDispatcher::removeStatusListener( const uno::Reference< X
const URL& aURL ) const URL& aURL )
throw( RuntimeException, std::exception ) throw( RuntimeException, std::exception )
{ {
// Ready for multithreading SolarMutexGuard g;
Guard aGuard( m_aLock );
// Safe impossible cases // Safe impossible cases
// Add listener to container. // Add listener to container.
m_aListenerContainer.removeInterface( aURL.Complete, xControl ); m_aListenerContainer.removeInterface( aURL.Complete, xControl );
...@@ -279,8 +268,7 @@ throw( RuntimeException, std::exception ) ...@@ -279,8 +268,7 @@ throw( RuntimeException, std::exception )
void SAL_CALL PopupMenuDispatcher::frameAction( const FrameActionEvent& aEvent ) void SAL_CALL PopupMenuDispatcher::frameAction( const FrameActionEvent& aEvent )
throw ( RuntimeException, std::exception ) throw ( RuntimeException, std::exception )
{ {
Guard aGuard( m_aLock ); SolarMutexGuard g;
if (( aEvent.Action == css::frame::FrameAction_COMPONENT_DETACHING ) || if (( aEvent.Action == css::frame::FrameAction_COMPONENT_DETACHING ) ||
( aEvent.Action == css::frame::FrameAction_COMPONENT_ATTACHED )) ( aEvent.Action == css::frame::FrameAction_COMPONENT_ATTACHED ))
{ {
...@@ -291,8 +279,7 @@ throw ( RuntimeException, std::exception ) ...@@ -291,8 +279,7 @@ throw ( RuntimeException, std::exception )
void SAL_CALL PopupMenuDispatcher::disposing( const EventObject& ) throw( RuntimeException, std::exception ) void SAL_CALL PopupMenuDispatcher::disposing( const EventObject& ) throw( RuntimeException, std::exception )
{ {
// Ready for multithreading SolarMutexGuard g;
Guard aGuard( m_aLock );
// Safe impossible cases // Safe impossible cases
SAL_WARN_IF( m_bAlreadyDisposed, "fwk", "MenuDispatcher::disposing(): Object already disposed .. don't call it again!" ); SAL_WARN_IF( m_bAlreadyDisposed, "fwk", "MenuDispatcher::disposing(): Object already disposed .. don't call it again!" );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment