cppuhelper/source/factory.cxx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
New commits: commit c945eafc99856f0bcd0a99195e2c5164c2a6d24a Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Thu Jan 12 20:44:10 2023 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Thu Jan 12 22:19:36 2023 +0000 Don't let OSingleFactoryHelper delegate to derived classes' virtual overrides ...as it doesn't make sense that e.g. OFactoryComponentHelper::createInstance checked for bOneInstance, called OSingleFactoryHelper::createInstance, which called [OFactoryComponentHelper::]createInstanceWithContext, which checked for bOneInstance again Change-Id: I53f54079a2ac1af18a6e95f0cb9d7b75c1e46ceb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145418 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/cppuhelper/source/factory.cxx b/cppuhelper/source/factory.cxx index c4797f85504a..37ac44ffa1a5 100644 --- a/cppuhelper/source/factory.cxx +++ b/cppuhelper/source/factory.cxx @@ -116,6 +116,11 @@ protected: ComponentFactoryFunc m_fptr; Sequence< OUString > aServiceNames; OUString aImplementationName; + +private: + css::uno::Reference<css::uno::XInterface> createInstanceWithArgumentsEveryTime( + css::uno::Sequence<css::uno::Any> const & rArguments, + css::uno::Reference<css::uno::XComponentContext> const & xContext); }; } @@ -160,14 +165,14 @@ Reference<XInterface > OSingleFactoryHelper::createInstanceEveryTime( // XSingleServiceFactory Reference<XInterface > OSingleFactoryHelper::createInstance() { - return createInstanceWithContext( Reference< XComponentContext >() ); + return createInstanceEveryTime( Reference< XComponentContext >() ); } // XSingleServiceFactory Reference<XInterface > OSingleFactoryHelper::createInstanceWithArguments( const Sequence<Any>& Arguments ) { - return createInstanceWithArgumentsAndContext( + return createInstanceWithArgumentsEveryTime( Arguments, Reference< XComponentContext >() ); } @@ -183,7 +188,15 @@ Reference< XInterface > OSingleFactoryHelper::createInstanceWithArgumentsAndCont Sequence< Any > const & rArguments, Reference< XComponentContext > const & xContext ) { - Reference< XInterface > xRet( createInstanceWithContext( xContext ) ); + return createInstanceWithArgumentsEveryTime(rArguments, xContext); +} + +css::uno::Reference<css::uno::XInterface> +OSingleFactoryHelper::createInstanceWithArgumentsEveryTime( + css::uno::Sequence<css::uno::Any> const & rArguments, + css::uno::Reference<css::uno::XComponentContext> const & xContext) +{ + Reference< XInterface > xRet( createInstanceEveryTime( xContext ) ); Reference< lang::XInitialization > xInit( xRet, UNO_QUERY ); // always call initialize, even if there are no arguments. #i63511#