summaryrefslogtreecommitdiffstats
path: root/cppuhelper
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-12-13 16:18:52 +0100
committerStephan Bergmann <sbergman@redhat.com>2013-12-13 16:18:52 +0100
commita4ed79bbf615fec10b39f46a5828ffea04d84f4e (patch)
tree867705e110de76b089ecb8a6150c5130bd836a28 /cppuhelper
parentassert non-nullness (diff)
downloadcore-a4ed79bbf615fec10b39f46a5828ffea04d84f4e.tar.gz
core-a4ed79bbf615fec10b39f46a5828ffea04d84f4e.zip
Shortcut common case of calling same-env component_getFactory fn
Change-Id: I7f5d31c3b3e128b2df4d83c915673bf7b5d2ab8c
Diffstat (limited to 'cppuhelper')
-rw-r--r--cppuhelper/source/shlib.cxx72
1 files changed, 41 insertions, 31 deletions
diff --git a/cppuhelper/source/shlib.cxx b/cppuhelper/source/shlib.cxx
index 8ad77f516190..ecb3f1fb4bff 100644
--- a/cppuhelper/source/shlib.cxx
+++ b/cppuhelper/source/shlib.cxx
@@ -188,47 +188,57 @@ Reference< XInterface > invokeComponentFactory(
fprintf(stderr, "invokeComponentFactory envDcp:%s implName:%s modPath:%s\n", envDcp.getStr(), implName.getStr(), modPath.getStr());
}
#endif
-
- Mapping aCurrent2Env( currentEnv, env );
- Mapping aEnv2Current( env, currentEnv );
-
- if (aCurrent2Env.is() && aEnv2Current.is())
+ if (env.get() == currentEnv.get())
{
- void * pSMgr = aCurrent2Env.mapInterface(
- xMgr.get(), ::getCppuType( &xMgr ) );
+ xRet.set(
+ static_cast<css::uno::XInterface *>(
+ (*reinterpret_cast<component_getFactoryFunc>(pGetter))(
+ aImplName.getStr(), xMgr.get(), 0)),
+ SAL_NO_ACQUIRE);
+ }
+ else
+ {
+ Mapping aCurrent2Env( currentEnv, env );
+ Mapping aEnv2Current( env, currentEnv );
- void * pSSF = NULL;
+ if (aCurrent2Env.is() && aEnv2Current.is())
+ {
+ void * pSMgr = aCurrent2Env.mapInterface(
+ xMgr.get(), ::getCppuType( &xMgr ) );
- env.invoke(s_getFactory, pGetter, &aImplName, pSMgr, 0, &pSSF);
+ void * pSSF = NULL;
- if (pSMgr)
- {
- (*env.get()->pExtEnv->releaseInterface)(
- env.get()->pExtEnv, pSMgr );
- }
+ env.invoke(s_getFactory, pGetter, &aImplName, pSMgr, 0, &pSSF);
- if (pSSF)
- {
- aEnv2Current.mapInterface(
- reinterpret_cast< void ** >( &xRet ),
- pSSF, ::getCppuType( &xRet ) );
- (env.get()->pExtEnv->releaseInterface)(
- env.get()->pExtEnv, pSSF );
+ if (pSMgr)
+ {
+ (*env.get()->pExtEnv->releaseInterface)(
+ env.get()->pExtEnv, pSMgr );
+ }
+
+ if (pSSF)
+ {
+ aEnv2Current.mapInterface(
+ reinterpret_cast< void ** >( &xRet ),
+ pSSF, ::getCppuType( &xRet ) );
+ (env.get()->pExtEnv->releaseInterface)(
+ env.get()->pExtEnv, pSSF );
+ }
+ else
+ {
+ rExcMsg = rModulePath +
+ ": cannot get factory of " +
+ "demanded implementation: " +
+ OStringToOUString(
+ aImplName, RTL_TEXTENCODING_ASCII_US );
+ }
}
else
{
- rExcMsg = rModulePath +
- ": cannot get factory of " +
- "demanded implementation: " +
- OStringToOUString(
- aImplName, RTL_TEXTENCODING_ASCII_US );
+ rExcMsg =
+ "cannot get uno mappings: C++ <=> UNO!";
}
}
- else
- {
- rExcMsg =
- "cannot get uno mappings: C++ <=> UNO!";
- }
}
else
{