[Libreoffice-commits] core.git: connectivity/source

Ariel Constenla-Haile arielch at apache.org
Fri Jun 7 06:14:28 PDT 2013


 connectivity/source/manager/mdrivermanager.cxx |   18 ++++++++++++------
 connectivity/source/manager/mdrivermanager.hxx |    1 -
 2 files changed, 12 insertions(+), 7 deletions(-)

New commits:
commit c154f180e22e5cd494b5c71453cb93f30fd71f6e
Author: Ariel Constenla-Haile <arielch at apache.org>
Date:   Mon Feb 4 16:54:16 2013 +0000

    Ensure UNO context propagation on drivers instantiation
    
    Use a better approach than 33c2427824ac893b15777527b818ec99c78c61dd
    
    (cherry picked from commit 7f635eeb69e1257a37c2d3bfe9afe5e56daf259c)
    
    Conflicts:
    	connectivity/source/manager/mdrivermanager.cxx
    	connectivity/source/manager/mdrivermanager.hxx
    
    Change-Id: Ic7ce5449d4c5e5231c838f9b7733fd4703e6252c

diff --git a/connectivity/source/manager/mdrivermanager.cxx b/connectivity/source/manager/mdrivermanager.cxx
index 6458cf0..67ea3ec 100644
--- a/connectivity/source/manager/mdrivermanager.cxx
+++ b/connectivity/source/manager/mdrivermanager.cxx
@@ -114,6 +114,9 @@ Any SAL_CALL ODriverEnumeration::nextElement(  ) throw(NoSuchElementException, W
     /// an STL functor which ensures that a SdbcDriver described by a DriverAccess is loaded
     struct EnsureDriver : public ::std::unary_function< DriverAccess, DriverAccess >
     {
+        EnsureDriver( const Reference< XComponentContext > &rxContext )
+            : mxContext( rxContext ) {}
+
         const DriverAccess& operator()( const DriverAccess& _rDescriptor ) const
         {
             if ( !_rDescriptor.xDriver.is() )
@@ -121,9 +124,12 @@ Any SAL_CALL ODriverEnumeration::nextElement(  ) throw(NoSuchElementException, W
                 if ( _rDescriptor.xComponentFactory.is() )
                     // we have a factory for it
                     const_cast< DriverAccess& >( _rDescriptor ).xDriver = _rDescriptor.xDriver.query(
-                        _rDescriptor.xComponentFactory->createInstanceWithContext( _rDescriptor.xUNOContext ) );
+                        _rDescriptor.xComponentFactory->createInstanceWithContext( mxContext ) );
             return _rDescriptor;
         }
+
+    private:
+        Reference< XComponentContext > mxContext;
     };
 
     /// an STL functor which extracts a SdbcDriver from a DriverAccess
@@ -139,7 +145,8 @@ Any SAL_CALL ODriverEnumeration::nextElement(  ) throw(NoSuchElementException, W
     /// an STL functor which loads a driver described by a DriverAccess, and extracts the SdbcDriver
     struct ExtractAfterLoad : public ExtractAfterLoad_BASE
     {
-        ExtractAfterLoad() : ExtractAfterLoad_BASE( ExtractDriverFromAccess(), EnsureDriver() ) { }
+        ExtractAfterLoad( const Reference< XComponentContext > &rxContext )
+            : ExtractAfterLoad_BASE( ExtractDriverFromAccess(), EnsureDriver( rxContext ) ) {}
     };
 
     struct ExtractDriverFromCollectionElement : public ::std::unary_function< DriverCollection::value_type, Reference<XDriver> >
@@ -287,7 +294,6 @@ void OSDBCDriverManager::bootstrapDrivers()
                 {   // yes -> no need to load the driver immediately (load it later when needed)
                     aDriverDescriptor.sImplementationName = xSI->getImplementationName();
                     aDriverDescriptor.xComponentFactory = xFactory;
-                    aDriverDescriptor.xUNOContext = m_xContext;
                     bValidDescriptor = sal_True;
 
                     m_aEventLogger.log( LogLevel::CONFIG,
@@ -475,7 +481,7 @@ Reference< XEnumeration > SAL_CALL OSDBCDriverManager::createEnumeration(  ) thr
     ODriverEnumeration::DriverArray aDrivers;
 
     // ensure that all our bootstrapped drivers are instantiated
-    ::std::for_each( m_aDriversBS.begin(), m_aDriversBS.end(), EnsureDriver() );
+    ::std::for_each( m_aDriversBS.begin(), m_aDriversBS.end(), EnsureDriver( m_xContext ) );
 
     // copy the bootstrapped drivers
     ::std::transform(
@@ -655,13 +661,13 @@ Reference< XDriver > OSDBCDriverManager::implGetDriverForURL(const OUString& _rU
             aFind = ::std::find_if(
                 m_aDriversBS.begin(),       // begin of search range
                 m_aDriversBS.end(),         // end of search range
-                o3tl::unary_compose< AcceptsURL, ExtractAfterLoad >( AcceptsURL( _rURL ), ExtractAfterLoad() )
+                o3tl::unary_compose< AcceptsURL, ExtractAfterLoad >( AcceptsURL( _rURL ), ExtractAfterLoad( m_xContext ) )
                                             // compose two functors: extract the driver from the access, then ask the resulting driver for acceptance
             );
         } // if ( m_aDriversBS.find(sDriverFactoryName ) == m_aDriversBS.end() )
         else
         {
-            EnsureDriver aEnsure;
+            EnsureDriver aEnsure( m_xContext );
             aEnsure(*aFind);
         }
 
diff --git a/connectivity/source/manager/mdrivermanager.hxx b/connectivity/source/manager/mdrivermanager.hxx
index be1e258..a311c02 100644
--- a/connectivity/source/manager/mdrivermanager.hxx
+++ b/connectivity/source/manager/mdrivermanager.hxx
@@ -47,7 +47,6 @@ namespace drivermanager
         OUString           sImplementationName;        /// the implementation name of the driver
         css::uno::Reference< css::sdbc::XDriver >                  xDriver;                    /// the driver itself
         css::uno::Reference< css::lang::XSingleComponentFactory >  xComponentFactory;          /// the factory to create the driver component (if not already done so)
-        css::uno::Reference<css::uno::XComponentContext>           xUNOContext;                /// ensure UNO context propagation
     };
 
     //==========================================================================


More information about the Libreoffice-commits mailing list