[Libreoffice-commits] core.git: cppuhelper/source
Stephan Bergmann
sbergman at redhat.com
Mon Jan 20 14:31:20 PST 2014
cppuhelper/source/servicemanager.cxx | 38 ++++++++++++-----------------------
cppuhelper/source/servicemanager.hxx | 2 -
2 files changed, 15 insertions(+), 25 deletions(-)
New commits:
commit 585d5621f17f0e70ae5bd2ad0a855ba8490d3b25
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Mon Jan 20 23:30:49 2014 +0100
Simplify code; STATUS_LOADED => component||factory1||factory2
Change-Id: I661eb69551eae3d888d156c6bd4291a532d0b6ab
diff --git a/cppuhelper/source/servicemanager.cxx b/cppuhelper/source/servicemanager.cxx
index af964fe..0eb30aa 100644
--- a/cppuhelper/source/servicemanager.cxx
+++ b/cppuhelper/source/servicemanager.cxx
@@ -711,13 +711,8 @@ cppuhelper::ServiceManager::Data::Implementation::createInstance(
if (factory1.is()) {
return factory1->createInstanceWithContext(context);
}
- if (factory2.is()) {
- return factory2->createInstance();
- }
- throw css::uno::DeploymentException(
- ("Implementation " + info->name
- + " does not provide a constructor or factory"),
- css::uno::Reference<css::uno::XInterface>());
+ assert(factory2.is());
+ return factory2->createInstance();
} else {
osl::MutexGuard g(mutex); //TODO: must be a non-recursive mutex
if (singleton.is()) {
@@ -732,13 +727,9 @@ cppuhelper::ServiceManager::Data::Implementation::createInstance(
context.get(), css::uno::Sequence<css::uno::Any>()));
} else if (factory1.is()) {
singleton = factory1->createInstanceWithContext(context);
- } else if (factory2.is()) {
- singleton = factory2->createInstance();
} else {
- throw css::uno::DeploymentException(
- ("Implementation " + info->name
- + " does not provide a constructor or factory"),
- css::uno::Reference<css::uno::XInterface>());
+ assert(factory2.is());
+ singleton = factory2->createInstance();
}
dispose = singleton.is() && !singletonRequest;
return singleton;
@@ -771,12 +762,8 @@ cppuhelper::ServiceManager::Data::Implementation::createInstanceWithArguments(
return factory1->createInstanceWithArgumentsAndContext(
arguments, context);
}
- if (factory2.is()) {
- return factory2->createInstanceWithArguments(arguments);
- }
- throw css::uno::DeploymentException(
- "Implementation " + info->name + " does not provide a factory",
- css::uno::Reference<css::uno::XInterface>());
+ assert(factory2.is());
+ return factory2->createInstanceWithArguments(arguments);
} else {
osl::MutexGuard g(mutex); //TODO: must be a non-recursive mutex
if (singleton.is()) {
@@ -800,12 +787,9 @@ cppuhelper::ServiceManager::Data::Implementation::createInstanceWithArguments(
} else if (factory1.is()) {
singleton = factory1->createInstanceWithArgumentsAndContext(
arguments, context);
- } else if (factory2.is()) {
- singleton = factory2->createInstanceWithArguments(arguments);
} else {
- throw css::uno::DeploymentException(
- "Implementation " + info->name + " does not provide a factory",
- css::uno::Reference<css::uno::XInterface>());
+ assert(factory2.is());
+ singleton = factory2->createInstanceWithArguments(arguments);
}
dispose = singleton.is() && !singletonRequest;
return singleton;
@@ -1694,6 +1678,12 @@ void cppuhelper::ServiceManager::insertLegacyFactory(
if (!f1.is()) {
f2 = css::uno::Reference< css::lang::XSingleServiceFactory >(
factoryInfo, css::uno::UNO_QUERY);
+ if (!f2.is()) {
+ throw css::lang::IllegalArgumentException(
+ ("Bad XServiceInfo argument implements neither"
+ " XSingleComponentFactory nor XSingleServiceFactory"),
+ static_cast< cppu::OWeakObject * >(this), 0);
+ }
}
css::uno::Reference< css::lang::XComponent > comp(
factoryInfo, css::uno::UNO_QUERY);
diff --git a/cppuhelper/source/servicemanager.hxx b/cppuhelper/source/servicemanager.hxx
index 8a3bc7f..a9522a5 100644
--- a/cppuhelper/source/servicemanager.hxx
+++ b/cppuhelper/source/servicemanager.hxx
@@ -121,7 +121,7 @@ public:
factory1(theFactory1), factory2(theFactory2),
component(theComponent), status(STATUS_LOADED),
dispose(false)
- {}
+ { assert(theFactory1.is() || theFactory2.is()); }
css::uno::Reference<css::uno::XInterface> createInstance(
css::uno::Reference<css::uno::XComponentContext> const &
More information about the Libreoffice-commits
mailing list