summaryrefslogtreecommitdiff
path: root/cppuhelper
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-10-27 10:37:26 +0200
committerStephan Bergmann <sbergman@redhat.com>2017-10-27 10:37:26 +0200
commit11cf64b7303d3c6bd2620d6c711c9845775f2d3d (patch)
treecfe4cdb2183c0dcaef5e959d74df97a167c546c4 /cppuhelper
parent8136a87d9af2cb6b7aecc6cf450d13904e155de8 (diff)
Better fix for CppunitTest_services
...than 25313923b08018bd837cfe3fc99a5e141602cafc "Fix CppunitTest_services for constructor-based implementations..." (which this commit reverts again). My claim that "the 'factory' would be the object itself" is nonsense, it would rather be an ImplementationWrapper (but one that was freshly created for each ServiceManager::createContentEnumeration). Change-Id: I85c683cff6f9ba78d0f8567a53f8fcbc56fe55cf
Diffstat (limited to 'cppuhelper')
-rw-r--r--cppuhelper/source/servicemanager.cxx10
-rw-r--r--cppuhelper/source/servicemanager.hxx11
2 files changed, 16 insertions, 5 deletions
diff --git a/cppuhelper/source/servicemanager.cxx b/cppuhelper/source/servicemanager.cxx
index 1478010d3434..8aa294ca0720 100644
--- a/cppuhelper/source/servicemanager.cxx
+++ b/cppuhelper/source/servicemanager.cxx
@@ -1172,15 +1172,15 @@ cppuhelper::ServiceManager::createContentEnumeration(
impl->factory1 = new ImplementationWrapper(this, *i);
impl->status = Data::Implementation::STATUS_WRAPPER;
}
+ if (impl->constructor != nullptr && !impl->factory1.is()) {
+ impl->factory1 = new ImplementationWrapper(this, *i);
+ }
}
if (impl->factory1.is()) {
factories.push_back(css::uno::Any(impl->factory1));
- } else if (impl->factory2.is()) {
- factories.push_back(css::uno::Any(impl->factory2));
} else {
- css::uno::Reference< css::lang::XSingleComponentFactory > factory(
- new ImplementationWrapper(this, *i));
- factories.push_back(css::uno::Any(factory));
+ assert(impl->factory2.is());
+ factories.push_back(css::uno::Any(impl->factory2));
}
}
return new ContentEnumeration(factories);
diff --git a/cppuhelper/source/servicemanager.hxx b/cppuhelper/source/servicemanager.hxx
index 2b1193e9a8d8..9838841403c1 100644
--- a/cppuhelper/source/servicemanager.hxx
+++ b/cppuhelper/source/servicemanager.hxx
@@ -150,6 +150,17 @@ public:
enum Status { STATUS_NEW, STATUS_WRAPPER, STATUS_LOADED };
+ // Logically, exactly one of constructor, factory1, factory2 should
+ // be set. However, there are two exceptions: For one, when
+ // constructor is set, ServiceManager::createContentEnumeration will
+ // store the necessary ImplementationWrapper in factory1 (so that
+ // multiple calls to createContentEnumeration will return the same
+ // wrapper). For another, when factory1 should be set but status is
+ // STATUS_NEW, factory1 is not yet set (and when status is
+ // STATUS_WRAPPER, factory1 is merely set to an
+ // ImplementationWrapper---also due to a
+ // ServiceManager::createContentEnumeration call---and will be
+ // loaded later).
std::shared_ptr< ImplementationInfo > info;
WrapperConstructorFn constructor;
css::uno::Reference< css::lang::XSingleComponentFactory > factory1;