diff options
-rw-r--r-- | cppuhelper/source/servicemanager.cxx | 10 | ||||
-rw-r--r-- | cppuhelper/source/servicemanager.hxx | 11 | ||||
-rw-r--r-- | postprocess/qa/services.cxx | 7 |
3 files changed, 23 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; diff --git a/postprocess/qa/services.cxx b/postprocess/qa/services.cxx index 78dee9ed3ad1..0ab677339d9d 100644 --- a/postprocess/qa/services.cxx +++ b/postprocess/qa/services.cxx @@ -209,6 +209,13 @@ void Test::test() { k = impls.insert( std::make_pair(name, Implementation(j, servs))) .first; + } else { + CPPUNIT_ASSERT_MESSAGE( + (OString( + "multiple implementations named \"" + msg(name) + + "\"") + .getStr()), + bool(j == k->second.factory)); } CPPUNIT_ASSERT_MESSAGE( (OString( |