Kaydet (Commit) 884ad0d1 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Split localProcessFactory function into class with setter and getter

...which avoids a false positive from an upcoming loplugin that finds suspicious
uses of variables during their own initialization (as happened with xReturn in
getProcessServiceFactory).

Change-Id: I40e90e2e74cde84a3425b014d87584f4a56c0e22
Reviewed-on: https://gerrit.libreoffice.org/70877
Tested-by: Jenkins
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst d7f4f565
...@@ -33,32 +33,44 @@ using namespace osl; ...@@ -33,32 +33,44 @@ using namespace osl;
namespace comphelper namespace comphelper
{ {
/* namespace {
This function preserves only that the xProcessFactory variable will not be create when
the library is loaded.
*/
static Reference< XMultiServiceFactory > localProcessFactory( const Reference< XMultiServiceFactory >& xSMgr, bool bSet )
{
Guard< Mutex > aGuard( Mutex::getGlobalMutex() );
static Reference< XMultiServiceFactory > xProcessFactory; class LocalProcessFactory {
if ( bSet ) public:
void set( const Reference< XMultiServiceFactory >& xSMgr )
{ {
Guard< Mutex > aGuard( Mutex::getGlobalMutex() );
xProcessFactory = xSMgr; xProcessFactory = xSMgr;
} }
Reference< XMultiServiceFactory > get()
{
Guard< Mutex > aGuard( Mutex::getGlobalMutex() );
return xProcessFactory; return xProcessFactory;
} }
private:
Reference< XMultiServiceFactory > xProcessFactory;
};
/*
This var preserves only that the above xProcessFactory variable will not be create when
the library is loaded.
*/
LocalProcessFactory localProcessFactory;
}
void setProcessServiceFactory(const Reference< XMultiServiceFactory >& xSMgr) void setProcessServiceFactory(const Reference< XMultiServiceFactory >& xSMgr)
{ {
localProcessFactory( xSMgr, true ); localProcessFactory.set( xSMgr );
} }
Reference< XMultiServiceFactory > getProcessServiceFactory() Reference< XMultiServiceFactory > getProcessServiceFactory()
{ {
Reference< XMultiServiceFactory> xReturn = localProcessFactory( xReturn, false ); Reference< XMultiServiceFactory> xReturn = localProcessFactory.get();
if ( !xReturn.is() ) if ( !xReturn.is() )
{ {
throw DeploymentException( "null process service factory" ); throw DeploymentException( "null process service factory" );
......
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