diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-04-02 15:12:00 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-04-02 17:22:21 +0200 |
commit | 86d298f87f00fe70d31a65b7e98f9b17fa80cb6b (patch) | |
tree | 0b7a389105ead641d092e56ff6fb1d49180f6265 /basic/source/classes | |
parent | 711ec7b6c71410b850cdf6d1411d054ca34ec5a0 (diff) |
Simplify some static variable initializations
Change-Id: I6cdd44aa66b9597ccc51fc3fd69b57485ccb3230
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113515
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'basic/source/classes')
-rw-r--r-- | basic/source/classes/sbunoobj.cxx | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index 9f00a8f231c9..fcd491462528 100644 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -233,22 +233,18 @@ static Reference< XTypeConverter > const & getTypeConverter_Impl() // #111851 factory function to create an OLE object SbUnoObject* createOLEObject_Impl( const OUString& aType ) { - static Reference< XMultiServiceFactory > xOLEFactory; - static bool bNeedsInit = true; - - if( bNeedsInit ) - { - bNeedsInit = false; - + static const Reference<XMultiServiceFactory> xOLEFactory = [] { + Reference<XMultiServiceFactory> xFactory; Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() ); if( xContext.is() ) { Reference<XMultiComponentFactory> xSMgr = xContext->getServiceManager(); - xOLEFactory.set( + xFactory.set( xSMgr->createInstanceWithContext( "com.sun.star.bridge.OleObjectFactory", xContext ), UNO_QUERY ); } - } + return xFactory; + }(); SbUnoObject* pUnoObj = nullptr; if( xOLEFactory.is() ) |