Date: prev next · Thread: first prev next last
2016 Archives by date, by thread · List index


On 24.02.2016 10:08, Stephan Bergmann wrote:
(This shows why 
comphelper::getProcessComponentContext is a convenient but dumb idea.) 

indeed, like all mutable global state.

diff --git a/comphelper/source/processfactory/processfactory.cxx 
b/comphelper/source/processfactory/processfactory.cxx
index 211067a..d7ca3af 100644
--- a/comphelper/source/processfactory/processfactory.cxx
+++ b/comphelper/source/processfactory/processfactory.cxx
@@ -18,6 +18,7 @@
  */

 #include <osl/mutex.hxx>
+#include <uno/environment.hxx>
 #include <comphelper/processfactory.hxx>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>

@@ -52,11 +53,17 @@ Reference< XMultiServiceFactory > localProcessFactory( const Reference< 
XMultiSe

 void setProcessServiceFactory(const Reference< XMultiServiceFactory >& xSMgr)
 {
+css::uno::Environment env(css::uno::Environment::getCurrent());
+assert(env.is());
+assert(env.getTypeName() == CPPU_CURRENT_LANGUAGE_BINDING_NAME);
     localProcessFactory( xSMgr, true );
 }

 Reference< XMultiServiceFactory > getProcessServiceFactory()
 {
+css::uno::Environment env(css::uno::Environment::getCurrent());
+assert(env.is());
+assert(env.getTypeName() == CPPU_CURRENT_LANGUAGE_BINDING_NAME);
     Reference< XMultiServiceFactory> xReturn;
     xReturn = localProcessFactory( xReturn, false );
     if ( !xReturn.is() )

could catch cases where it erroneously gets called from within a purpose 
environment.  Then again, purpose environments are rare enough in 
practice, and I only found a single problematic 
<https://cgit.freedesktop.org/libreoffice/core/commit/?id=9610a5aebd3ffdf76bcb734c633b5f88b78ad4dd>
 
"Use passed-in context instead of 
comphelper::getProcessComponentContext()" when running "make check" with 
that patch enabled.  So it might not be worth it to commit that.

well that's what we have *today* - who knows what will be added (or
"cleaned up") in the future, better add the asserts.



Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.