Bugzilla – Attachment 122936 Details for
Bug 98128
Missing support for UNO component constructor in non-standard environment
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
first step towards a fix
SERVICEMANAGER-MAPPING-TODO.patch (text/plain), 6.20 KB, created by
Stephan Bergmann
on 2016-02-24 08:35:09 UTC
(
hide
)
Description:
first step towards a fix
Filename:
MIME Type:
Creator:
Stephan Bergmann
Created:
2016-02-24 08:35:09 UTC
Size:
6.20 KB
patch
obsolete
>diff --git a/cppuhelper/source/servicemanager.cxx b/cppuhelper/source/servicemanager.cxx >index 0f709ef..28bc95b 100644 >--- a/cppuhelper/source/servicemanager.cxx >+++ b/cppuhelper/source/servicemanager.cxx >@@ -11,6 +11,7 @@ > > #include <algorithm> > #include <cassert> >+#include <cstdlib> > #include <vector> > > #include <boost/noncopyable.hpp> >@@ -43,6 +44,7 @@ > #include <rtl/strbuf.hxx> > #include <sal/log.hxx> > #include <uno/environment.hxx> >+#include <uno/mapping.hxx> > > #include "loadsharedlibcomponentfactory.hxx" > >@@ -672,6 +674,16 @@ ImplementationWrapper::getSupportedServiceNames() > return names; > } > >+extern "C" void callConstructor(va_list * args) { >+ cppuhelper::ImplementationConstructorFn * ctor = va_arg( >+ *args, cppuhelper::ImplementationConstructorFn *); >+ void * ctxt = va_arg(*args, void *); >+ void ** inst = va_arg(*args, void **); >+ *inst = (*ctor)( >+ static_cast<css::uno::XComponentContext *>(ctxt), >+ css::uno::Sequence<css::uno::Any>()); >+} >+ > } > > css::uno::Reference<css::uno::XInterface> >@@ -681,11 +693,9 @@ cppuhelper::ServiceManager::Data::Implementation::createInstance( > { > css::uno::Reference<css::uno::XInterface> inst; > if (constructor != nullptr) { >- inst.set( >- (*constructor)(context.get(), css::uno::Sequence<css::uno::Any>()), >- SAL_NO_ACQUIRE); >+ inst = invokeConstructor(context, css::uno::Sequence<css::uno::Any>()); > } else if (factory1.is()) { >- inst = factory1->createInstanceWithContext(context); >+ inst = factory1->createInstanceWithContext(context); > } else { > assert(factory2.is()); > inst = factory2->createInstance(); >@@ -701,7 +711,7 @@ cppuhelper::ServiceManager::Data::Implementation::createInstanceWithArguments( > { > css::uno::Reference<css::uno::XInterface> inst; > if (constructor != nullptr) { >- inst.set((*constructor)(context.get(), arguments), SAL_NO_ACQUIRE); >+ inst = invokeConstructor(context, arguments); > //HACK: The constructor will either observe arguments and return inst > // that does not implement XInitialization (or null), or ignore > // arguments and return inst that implements XInitialization; this >@@ -723,6 +733,52 @@ cppuhelper::ServiceManager::Data::Implementation::createInstanceWithArguments( > return inst; > } > >+css::uno::Reference<css::uno::XInterface> >+cppuhelper::ServiceManager::Data::Implementation::invokeConstructor( >+ css::uno::Reference<css::uno::XComponentContext> const & context, >+ css::uno::Sequence<css::uno::Any> const & arguments) const >+{ >+ assert(constructor != nullptr); >+ assert(!info->environment.isEmpty()); >+ css::uno::Environment curEnv(css::uno::Environment::getCurrent()); >+ css::uno::Environment env( >+ cppuhelper::detail::getEnvironment(info->environment, info->name)); >+ if (!(curEnv.is() && env.is())) { >+ throw css::uno::DeploymentException( >+ "cannot get environments", >+ css::uno::Reference<css::uno::XInterface>()); >+ } >+ if (curEnv.get() == env.get()) { >+ return css::uno::Reference<css::uno::XInterface>( >+ (*constructor)(context.get(), arguments), SAL_NO_ACQUIRE); >+ } else { >+SAL_DEBUG("SBSBSB <"<<curEnv.getTypeName()<<"> <"<<env.getTypeName()<<">"); >+assert(false);//SB >+ assert(!arguments.hasElements()); //TODO >+ css::uno::Mapping mapTo(curEnv, env); >+ css::uno::Mapping mapFrom(env, curEnv); >+ if (!(mapTo.is() && mapFrom.is())) { >+ throw css::uno::DeploymentException( >+ "cannot get mappings", >+ css::uno::Reference<css::uno::XInterface>()); >+ } >+ void * contextExt = mapTo.mapInterface( >+ context.get(), cppu::UnoType<css::uno::XComponentContext>::get()); >+ void * instExt = nullptr; >+ env.invoke(callConstructor, constructor, contextExt, &instExt); >+ if (contextExt != nullptr) { >+ (*env.get()->pExtEnv->releaseInterface)( >+ env.get()->pExtEnv, contextExt); >+ } >+ css::uno::Reference<css::uno::XInterface> inst; >+ mapFrom.mapInterface( >+ reinterpret_cast<void **>(&inst), instExt, >+ cppu::UnoType<css::uno::XInterface>::get()); >+ // instExt was unacquired, so don't release >+ return inst; >+ } >+} >+ > void cppuhelper::ServiceManager::Data::Implementation::updateDisposeSingleton( > bool singletonRequest, > css::uno::Reference<css::uno::XInterface> const & instance) >@@ -802,22 +858,6 @@ void cppuhelper::ServiceManager::loadImplementation( > uri, implementation->info->environment, > implementation->info->prefix, implementation->info->name, > implementation->info->constructor, this, &ctor, &f0); >- if (ctor != nullptr) { >- assert(!implementation->info->environment.isEmpty()); >- css::uno::Environment curEnv(css::uno::Environment::getCurrent()); >- css::uno::Environment env( >- cppuhelper::detail::getEnvironment( >- implementation->info->environment, >- implementation->info->name)); >- if (!(curEnv.is() && env.is())) { >- throw css::uno::DeploymentException( >- "cannot get environments", >- css::uno::Reference<css::uno::XInterface>()); >- } >- if (curEnv.get() != env.get()) { >- std::abort();//TODO >- } >- } > } else { > SAL_WARN_IF( > !implementation->info->environment.isEmpty(), "cppuhelper", >diff --git a/cppuhelper/source/servicemanager.hxx b/cppuhelper/source/servicemanager.hxx >index 7e8f4e6..7c42e4c 100644 >--- a/cppuhelper/source/servicemanager.hxx >+++ b/cppuhelper/source/servicemanager.hxx >@@ -150,6 +150,11 @@ public: > bool dispose; > > private: >+ css::uno::Reference<css::uno::XInterface> invokeConstructor( >+ css::uno::Reference<css::uno::XComponentContext> const & >+ context, >+ css::uno::Sequence<css::uno::Any> const & arguments) const; >+ > void updateDisposeSingleton( > bool singletonRequest, > css::uno::Reference<css::uno::XInterface> const & instance);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 98128
: 122936