Kaydet (Commit) 1cdb7923 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Make VCLSession into a OneInstanceFactory

...so no need to hold the one instance as ImplSVData::xSMClient.  Nor as
VCLSession::pOneInstance, after changing SalSession::SetCallback to carry
VCLSession* as user data.

Change-Id: I3180d72035e3da7aa164a20309fbaeccecbb9b65
üst b11de026
...@@ -84,25 +84,27 @@ struct SalSessionQuitEvent : public SalSessionEvent ...@@ -84,25 +84,27 @@ struct SalSessionQuitEvent : public SalSessionEvent
{} {}
}; };
typedef void(*SessionProc)( SalSessionEvent *pEvent); typedef void(*SessionProc)(void *pData, SalSessionEvent *pEvent);
class VCL_PLUGIN_PUBLIC SalSession class VCL_PLUGIN_PUBLIC SalSession
{ {
SessionProc m_aProc; SessionProc m_aProc;
void * m_pProcData;
public: public:
SalSession() SalSession()
: m_aProc( 0 ) : m_aProc( 0 )
{} {}
virtual ~SalSession(); virtual ~SalSession();
void SetCallback( SessionProc aCallback ) void SetCallback( SessionProc aCallback, void * pCallbackData )
{ {
m_aProc = aCallback; m_aProc = aCallback;
m_pProcData = pCallbackData;
} }
void CallCallback( SalSessionEvent* pEvent ) void CallCallback( SalSessionEvent* pEvent )
{ {
if( m_aProc ) if( m_aProc )
m_aProc( pEvent ); m_aProc( m_pProcData, pEvent );
} }
// query the session manager for a user interaction slot // query the session manager for a user interaction slot
......
...@@ -53,16 +53,9 @@ ...@@ -53,16 +53,9 @@
#include <boost/unordered_map.hpp> #include <boost/unordered_map.hpp>
namespace com { namespace com { namespace sun { namespace star { namespace lang {
namespace sun {
namespace star {
namespace lang {
class XMultiServiceFactory; class XMultiServiceFactory;
} } } } }
namespace frame {
class XSessionManagerClient;
}
}}}
struct ImplTimerData; struct ImplTimerData;
struct ImplFileImageCacheData; struct ImplFileImageCacheData;
...@@ -366,7 +359,6 @@ struct ImplSVData ...@@ -366,7 +359,6 @@ struct ImplSVData
rtl::Reference< vcl::DisplayConnection > mxDisplayConnection; rtl::Reference< vcl::DisplayConnection > mxDisplayConnection;
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxAccessBridge; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxAccessBridge;
com::sun::star::uno::Reference< com::sun::star::frame::XSessionManagerClient > xSMClient;
::vcl::SettingsConfigItem* mpSettingsConfigItem; ::vcl::SettingsConfigItem* mpSettingsConfigItem;
std::list< vcl::DeleteOnDeinitBase* >* mpDeinitDeleteList; std::list< vcl::DeleteOnDeinitBase* >* mpDeinitDeleteList;
boost::unordered_map< int, rtl::OUString >* mpPaperNames; boost::unordered_map< int, rtl::OUString >* mpPaperNames;
......
...@@ -84,8 +84,7 @@ class VCLSession : public cppu::WeakComponentImplHelper1 < XSessionManagerClient ...@@ -84,8 +84,7 @@ class VCLSession : public cppu::WeakComponentImplHelper1 < XSessionManagerClient
bool m_bInteractionDone; bool m_bInteractionDone;
bool m_bSaveDone; bool m_bSaveDone;
static void SalSessionEventProc( SalSessionEvent* pEvent ); static void SalSessionEventProc( void* pData, SalSessionEvent* pEvent );
static VCLSession* pOneInstance;
void callSaveRequested( bool bShutdown, bool bCancelable ); void callSaveRequested( bool bShutdown, bool bCancelable );
void callShutdownCancelled(); void callShutdownCancelled();
...@@ -103,8 +102,6 @@ public: ...@@ -103,8 +102,6 @@ public:
virtual sal_Bool SAL_CALL cancelShutdown() throw( RuntimeException ); virtual sal_Bool SAL_CALL cancelShutdown() throw( RuntimeException );
}; };
VCLSession* VCLSession::pOneInstance = NULL;
VCLSession::VCLSession() VCLSession::VCLSession()
: cppu::WeakComponentImplHelper1< XSessionManagerClient >( m_aMutex ), : cppu::WeakComponentImplHelper1< XSessionManagerClient >( m_aMutex ),
m_bInteractionRequested( false ), m_bInteractionRequested( false ),
...@@ -112,17 +109,13 @@ VCLSession::VCLSession() ...@@ -112,17 +109,13 @@ VCLSession::VCLSession()
m_bInteractionDone( false ), m_bInteractionDone( false ),
m_bSaveDone( false ) m_bSaveDone( false )
{ {
DBG_ASSERT( pOneInstance == 0, "One instance of VCLSession only !" );
pOneInstance = this;
m_pSession = ImplGetSVData()->mpDefInst->CreateSalSession(); m_pSession = ImplGetSVData()->mpDefInst->CreateSalSession();
if( m_pSession ) if( m_pSession )
m_pSession->SetCallback( SalSessionEventProc ); m_pSession->SetCallback( SalSessionEventProc, this );
} }
VCLSession::~VCLSession() VCLSession::~VCLSession()
{ {
DBG_ASSERT( pOneInstance == this, "Another instance of VCLSession in destructor !" );
pOneInstance = NULL;
delete m_pSession; delete m_pSession;
} }
...@@ -230,27 +223,28 @@ void VCLSession::callQuit() ...@@ -230,27 +223,28 @@ void VCLSession::callQuit()
Application::AcquireSolarMutex( nAcquireCount ); Application::AcquireSolarMutex( nAcquireCount );
} }
void VCLSession::SalSessionEventProc( SalSessionEvent* pEvent ) void VCLSession::SalSessionEventProc( void* pData, SalSessionEvent* pEvent )
{ {
VCLSession * pThis = static_cast< VCLSession * >( pData );
switch( pEvent->m_eType ) switch( pEvent->m_eType )
{ {
case Interaction: case Interaction:
{ {
SalSessionInteractionEvent* pIEv = static_cast<SalSessionInteractionEvent*>(pEvent); SalSessionInteractionEvent* pIEv = static_cast<SalSessionInteractionEvent*>(pEvent);
pOneInstance->callInteractionGranted( pIEv->m_bInteractionGranted ); pThis->callInteractionGranted( pIEv->m_bInteractionGranted );
} }
break; break;
case SaveRequest: case SaveRequest:
{ {
SalSessionSaveRequestEvent* pSEv = static_cast<SalSessionSaveRequestEvent*>(pEvent); SalSessionSaveRequestEvent* pSEv = static_cast<SalSessionSaveRequestEvent*>(pEvent);
pOneInstance->callSaveRequested( pSEv->m_bShutdown, pSEv->m_bCancelable ); pThis->callSaveRequested( pSEv->m_bShutdown, pSEv->m_bCancelable );
} }
break; break;
case ShutdownCancel: case ShutdownCancel:
pOneInstance->callShutdownCancelled(); pThis->callShutdownCancelled();
break; break;
case Quit: case Quit:
pOneInstance->callQuit(); pThis->callQuit();
break; break;
} }
} }
...@@ -372,11 +366,7 @@ Sequence< rtl::OUString > SAL_CALL vcl_session_getSupportedServiceNames() ...@@ -372,11 +366,7 @@ Sequence< rtl::OUString > SAL_CALL vcl_session_getSupportedServiceNames()
css::uno::Reference< XInterface > SAL_CALL vcl_session_createInstance( const css::uno::Reference< XMultiServiceFactory > & /*xMultiServiceFactory*/ ) css::uno::Reference< XInterface > SAL_CALL vcl_session_createInstance( const css::uno::Reference< XMultiServiceFactory > & /*xMultiServiceFactory*/ )
{ {
ImplSVData* pSVData = ImplGetSVData(); return static_cast< cppu::OWeakObject * >(new VCLSession);
if( ! pSVData->xSMClient.is() )
pSVData->xSMClient = new VCLSession();
return css::uno::Reference< XInterface >(pSVData->xSMClient, UNO_QUERY );
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -95,7 +95,7 @@ extern "C" { ...@@ -95,7 +95,7 @@ extern "C" {
Reference< ::com::sun::star::lang::XSingleServiceFactory > xFactory; Reference< ::com::sun::star::lang::XSingleServiceFactory > xFactory;
if( vcl_session_getImplementationName().equalsAscii( pImplementationName ) ) if( vcl_session_getImplementationName().equalsAscii( pImplementationName ) )
{ {
xFactory = ::cppu::createSingleFactory( xFactory = ::cppu::createOneInstanceFactory(
xMgr, vcl_session_getImplementationName(), vcl_session_createInstance, xMgr, vcl_session_getImplementationName(), vcl_session_createInstance,
vcl_session_getSupportedServiceNames() ); vcl_session_getSupportedServiceNames() );
} }
......
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