Use SolarMutexGuard directly
(and access safe data members directly) Change-Id: I4a033fc2acd858534d329023c72c278f8b4b9244
This commit is contained in:
@@ -21,7 +21,6 @@
|
|||||||
#define INCLUDED_FRAMEWORK_INC_DISPATCH_DISPATCHPROVIDER_HXX
|
#define INCLUDED_FRAMEWORK_INC_DISPATCH_DISPATCHPROVIDER_HXX
|
||||||
|
|
||||||
#include <classes/protocolhandlercache.hxx>
|
#include <classes/protocolhandlercache.hxx>
|
||||||
#include <threadhelp/threadhelpbase.hxx>
|
|
||||||
|
|
||||||
#include <threadhelp/transactionbase.hxx>
|
#include <threadhelp/transactionbase.hxx>
|
||||||
#include <macros/xinterface.hxx>
|
#include <macros/xinterface.hxx>
|
||||||
@@ -69,18 +68,13 @@ enum EDispatchHelper
|
|||||||
@attention Use this class as member only! Never use it as baseclass.
|
@attention Use this class as member only! Never use it as baseclass.
|
||||||
XInterface will be ambigous and we hold a weakreference to ouer OWNER - not to ouer SUPERCLASS!
|
XInterface will be ambigous and we hold a weakreference to ouer OWNER - not to ouer SUPERCLASS!
|
||||||
|
|
||||||
@base ThreadHelpBase
|
|
||||||
supports threadsafe mechanism
|
|
||||||
@base OWeakObject
|
@base OWeakObject
|
||||||
provides ref count and weak mechanism
|
provides ref count and weak mechanism
|
||||||
|
|
||||||
@devstatus ready to use
|
@devstatus ready to use
|
||||||
@threadsafe yes
|
@threadsafe yes
|
||||||
*/
|
*/
|
||||||
class DispatchProvider : // baseclasses
|
class DispatchProvider : private TransactionBase ,
|
||||||
// Order is necessary for right initialization!
|
|
||||||
private ThreadHelpBase ,
|
|
||||||
private TransactionBase ,
|
|
||||||
// interfaces
|
// interfaces
|
||||||
public ::cppu::WeakImplHelper1< css::frame::XDispatchProvider >
|
public ::cppu::WeakImplHelper1< css::frame::XDispatchProvider >
|
||||||
{
|
{
|
||||||
|
@@ -27,7 +27,6 @@
|
|||||||
|
|
||||||
#include <pattern/window.hxx>
|
#include <pattern/window.hxx>
|
||||||
#include <threadhelp/transactionguard.hxx>
|
#include <threadhelp/transactionguard.hxx>
|
||||||
#include <threadhelp/guard.hxx>
|
|
||||||
#include <dispatchcommands.h>
|
#include <dispatchcommands.h>
|
||||||
#include <protocols.h>
|
#include <protocols.h>
|
||||||
#include <services.h>
|
#include <services.h>
|
||||||
@@ -64,10 +63,7 @@ namespace framework{
|
|||||||
*/
|
*/
|
||||||
DispatchProvider::DispatchProvider( const css::uno::Reference< css::uno::XComponentContext >& rxContext ,
|
DispatchProvider::DispatchProvider( const css::uno::Reference< css::uno::XComponentContext >& rxContext ,
|
||||||
const css::uno::Reference< css::frame::XFrame >& xFrame )
|
const css::uno::Reference< css::frame::XFrame >& xFrame )
|
||||||
// Init baseclasses first
|
: m_xContext ( rxContext )
|
||||||
: ThreadHelpBase( &Application::GetSolarMutex() )
|
|
||||||
// Init member
|
|
||||||
, m_xContext ( rxContext )
|
|
||||||
, m_xFrame ( xFrame )
|
, m_xFrame ( xFrame )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -105,11 +101,7 @@ css::uno::Reference< css::frame::XDispatch > SAL_CALL DispatchProvider::queryDis
|
|||||||
{
|
{
|
||||||
css::uno::Reference< css::frame::XDispatch > xDispatcher;
|
css::uno::Reference< css::frame::XDispatch > xDispatcher;
|
||||||
|
|
||||||
/* SAFE { */
|
css::uno::Reference< css::frame::XFrame > xOwner(m_xFrame);
|
||||||
Guard aReadLock( m_aLock );
|
|
||||||
css::uno::Reference< css::frame::XFrame > xOwner( m_xFrame.get(), css::uno::UNO_QUERY );
|
|
||||||
aReadLock.unlock();
|
|
||||||
/* } SAFE */
|
|
||||||
|
|
||||||
css::uno::Reference< css::frame::XDesktop > xDesktopCheck( xOwner, css::uno::UNO_QUERY );
|
css::uno::Reference< css::frame::XDesktop > xDesktopCheck( xOwner, css::uno::UNO_QUERY );
|
||||||
|
|
||||||
@@ -490,42 +482,40 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_searchProt
|
|||||||
// This member is threadsafe by himself and lives if we live - we don't need any mutex here.
|
// This member is threadsafe by himself and lives if we live - we don't need any mutex here.
|
||||||
if (m_aProtocolHandlerCache.search(aURL,&aHandler))
|
if (m_aProtocolHandlerCache.search(aURL,&aHandler))
|
||||||
{
|
{
|
||||||
/* SAFE { */
|
|
||||||
Guard aReadLock( m_aLock );
|
|
||||||
|
|
||||||
// create it
|
|
||||||
css::uno::Reference< css::frame::XDispatchProvider > xHandler;
|
css::uno::Reference< css::frame::XDispatchProvider > xHandler;
|
||||||
try
|
|
||||||
{
|
{
|
||||||
xHandler = css::uno::Reference< css::frame::XDispatchProvider >(
|
SolarMutexGuard g;
|
||||||
css::uno::Reference<css::lang::XMultiServiceFactory>(m_xContext->getServiceManager(), css::uno::UNO_QUERY_THROW)
|
|
||||||
->createInstance(aHandler.m_sUNOName),
|
|
||||||
css::uno::UNO_QUERY);
|
|
||||||
}
|
|
||||||
catch(const css::uno::Exception&) {}
|
|
||||||
|
|
||||||
// look if initialization is necessary
|
// create it
|
||||||
css::uno::Reference< css::lang::XInitialization > xInit( xHandler, css::uno::UNO_QUERY );
|
try
|
||||||
if (xInit.is())
|
|
||||||
{
|
|
||||||
css::uno::Reference< css::frame::XFrame > xOwner( m_xFrame.get(), css::uno::UNO_QUERY );
|
|
||||||
SAL_WARN_IF(!xOwner.is(), "fwk", "DispatchProvider::implts_searchProtocolHandler(): Couldn't get reference to my owner frame. So I can't set may needed context information for this protocol handler.");
|
|
||||||
if (xOwner.is())
|
|
||||||
{
|
{
|
||||||
try
|
xHandler = css::uno::Reference< css::frame::XDispatchProvider >(
|
||||||
|
css::uno::Reference<css::lang::XMultiServiceFactory>(m_xContext->getServiceManager(), css::uno::UNO_QUERY_THROW)
|
||||||
|
->createInstance(aHandler.m_sUNOName),
|
||||||
|
css::uno::UNO_QUERY);
|
||||||
|
}
|
||||||
|
catch(const css::uno::Exception&) {}
|
||||||
|
|
||||||
|
// look if initialization is necessary
|
||||||
|
css::uno::Reference< css::lang::XInitialization > xInit( xHandler, css::uno::UNO_QUERY );
|
||||||
|
if (xInit.is())
|
||||||
|
{
|
||||||
|
css::uno::Reference< css::frame::XFrame > xOwner( m_xFrame.get(), css::uno::UNO_QUERY );
|
||||||
|
SAL_WARN_IF(!xOwner.is(), "fwk", "DispatchProvider::implts_searchProtocolHandler(): Couldn't get reference to my owner frame. So I can't set may needed context information for this protocol handler.");
|
||||||
|
if (xOwner.is())
|
||||||
{
|
{
|
||||||
// but do it only, if all context information are OK
|
try
|
||||||
css::uno::Sequence< css::uno::Any > lContext(1);
|
{
|
||||||
lContext[0] <<= xOwner;
|
// but do it only, if all context information are OK
|
||||||
xInit->initialize(lContext);
|
css::uno::Sequence< css::uno::Any > lContext(1);
|
||||||
|
lContext[0] <<= xOwner;
|
||||||
|
xInit->initialize(lContext);
|
||||||
|
}
|
||||||
|
catch(const css::uno::Exception&) {}
|
||||||
}
|
}
|
||||||
catch(const css::uno::Exception&) {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
aReadLock.unlock();
|
|
||||||
/* } SAFE */
|
|
||||||
|
|
||||||
// ask for his (sub)dispatcher for the given URL
|
// ask for his (sub)dispatcher for the given URL
|
||||||
if (xHandler.is())
|
if (xHandler.is())
|
||||||
xDispatcher = xHandler->queryDispatch(aURL,SPECIALTARGET_SELF,0);
|
xDispatcher = xHandler->queryDispatch(aURL,SPECIALTARGET_SELF,0);
|
||||||
@@ -566,34 +556,25 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_getOrCreat
|
|||||||
{
|
{
|
||||||
css::uno::Reference< css::frame::XDispatch > xDispatchHelper;
|
css::uno::Reference< css::frame::XDispatch > xDispatchHelper;
|
||||||
|
|
||||||
/* SAFE { */
|
|
||||||
Guard aReadLock( m_aLock );
|
|
||||||
css::uno::Reference< css::uno::XComponentContext > xContext = m_xContext;
|
|
||||||
aReadLock.unlock();
|
|
||||||
/* } SAFE */
|
|
||||||
|
|
||||||
switch (eHelper)
|
switch (eHelper)
|
||||||
{
|
{
|
||||||
case E_MENUDISPATCHER :
|
case E_MENUDISPATCHER :
|
||||||
{
|
{
|
||||||
// Attention: Such menue dispatcher must be a singleton for this frame - means our owner frame.
|
// Attention: Such menue dispatcher must be a singleton for this frame - means our owner frame.
|
||||||
// Otherwhise he can make some trouble.
|
// Otherwhise he can make some trouble.
|
||||||
/* SAFE { */
|
SolarMutexGuard g;
|
||||||
Guard aWriteLock( m_aLock );
|
|
||||||
if ( ! m_xMenuDispatcher.is() )
|
if ( ! m_xMenuDispatcher.is() )
|
||||||
{
|
{
|
||||||
MenuDispatcher* pDispatcher = new MenuDispatcher( xContext, xOwner );
|
MenuDispatcher* pDispatcher = new MenuDispatcher( m_xContext, xOwner );
|
||||||
m_xMenuDispatcher = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY );
|
m_xMenuDispatcher = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY );
|
||||||
}
|
}
|
||||||
xDispatchHelper = m_xMenuDispatcher;
|
xDispatchHelper = m_xMenuDispatcher;
|
||||||
aWriteLock.unlock();
|
|
||||||
/* } SAFE */
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case E_CREATEDISPATCHER :
|
case E_CREATEDISPATCHER :
|
||||||
{
|
{
|
||||||
LoadDispatcher* pDispatcher = new LoadDispatcher(xContext, xOwner, sTarget, nSearchFlags);
|
LoadDispatcher* pDispatcher = new LoadDispatcher(m_xContext, xOwner, sTarget, nSearchFlags);
|
||||||
xDispatchHelper = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY );
|
xDispatchHelper = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -603,7 +584,7 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_getOrCreat
|
|||||||
css::uno::Reference< css::frame::XFrame > xDesktop( xOwner, css::uno::UNO_QUERY );
|
css::uno::Reference< css::frame::XFrame > xDesktop( xOwner, css::uno::UNO_QUERY );
|
||||||
if (xDesktop.is())
|
if (xDesktop.is())
|
||||||
{
|
{
|
||||||
LoadDispatcher* pDispatcher = new LoadDispatcher(xContext, xOwner, SPECIALTARGET_BLANK, 0);
|
LoadDispatcher* pDispatcher = new LoadDispatcher(m_xContext, xOwner, SPECIALTARGET_BLANK, 0);
|
||||||
xDispatchHelper = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY );
|
xDispatchHelper = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -614,7 +595,7 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_getOrCreat
|
|||||||
css::uno::Reference< css::frame::XFrame > xDesktop( xOwner, css::uno::UNO_QUERY );
|
css::uno::Reference< css::frame::XFrame > xDesktop( xOwner, css::uno::UNO_QUERY );
|
||||||
if (xDesktop.is())
|
if (xDesktop.is())
|
||||||
{
|
{
|
||||||
LoadDispatcher* pDispatcher = new LoadDispatcher(xContext, xOwner, SPECIALTARGET_DEFAULT, 0);
|
LoadDispatcher* pDispatcher = new LoadDispatcher(m_xContext, xOwner, SPECIALTARGET_DEFAULT, 0);
|
||||||
xDispatchHelper = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY );
|
xDispatchHelper = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -622,21 +603,21 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_getOrCreat
|
|||||||
|
|
||||||
case E_SELFDISPATCHER :
|
case E_SELFDISPATCHER :
|
||||||
{
|
{
|
||||||
LoadDispatcher* pDispatcher = new LoadDispatcher(xContext, xOwner, SPECIALTARGET_SELF, 0);
|
LoadDispatcher* pDispatcher = new LoadDispatcher(m_xContext, xOwner, SPECIALTARGET_SELF, 0);
|
||||||
xDispatchHelper = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY );
|
xDispatchHelper = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case E_CLOSEDISPATCHER :
|
case E_CLOSEDISPATCHER :
|
||||||
{
|
{
|
||||||
CloseDispatcher* pDispatcher = new CloseDispatcher( xContext, xOwner, sTarget );
|
CloseDispatcher* pDispatcher = new CloseDispatcher( m_xContext, xOwner, sTarget );
|
||||||
xDispatchHelper = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY );
|
xDispatchHelper = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case E_STARTMODULEDISPATCHER :
|
case E_STARTMODULEDISPATCHER :
|
||||||
{
|
{
|
||||||
StartModuleDispatcher* pDispatcher = new StartModuleDispatcher( xContext, xOwner, sTarget );
|
StartModuleDispatcher* pDispatcher = new StartModuleDispatcher( m_xContext, xOwner, sTarget );
|
||||||
xDispatchHelper = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY );
|
xDispatchHelper = css::uno::Reference< css::frame::XDispatch >( static_cast< ::cppu::OWeakObject* >(pDispatcher), css::uno::UNO_QUERY );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user