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

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Thu Oct 1 07:46:19 UTC 2020


 connectivity/source/manager/mdrivermanager.cxx |   24 +++---------------------
 connectivity/source/manager/mdrivermanager.hxx |    3 ---
 connectivity/source/manager/sdbc2.component    |    4 +---
 3 files changed, 4 insertions(+), 27 deletions(-)

New commits:
commit d9ba652064ee760448d0344d07347480cb195b6e
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Wed Sep 30 22:19:39 2020 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Thu Oct 1 09:45:22 2020 +0200

    Use the new single-instance="true" attribute in connectivity
    
    Change-Id: Ie49207b659214163f2f57051ac8f9de02fab36c7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103735
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/connectivity/source/manager/mdrivermanager.cxx b/connectivity/source/manager/mdrivermanager.cxx
index 71bcb6c9e816..ae1e226cd2fc 100644
--- a/connectivity/source/manager/mdrivermanager.cxx
+++ b/connectivity/source/manager/mdrivermanager.cxx
@@ -29,17 +29,13 @@
 #include <tools/diagnose_ex.h>
 #include <cppuhelper/implbase.hxx>
 #include <cppuhelper/supportsservice.hxx>
+#include <cppuhelper/weak.hxx>
 #include <osl/diagnose.h>
-#include <rtl/ref.hxx>
 
 #include <algorithm>
 #include <iterator>
 #include <vector>
 
-static osl::Mutex g_InstanceGuard;
-static rtl::Reference<drivermanager::OSDBCDriverManager> g_Instance;
-static bool g_Disposed = false;
-
 namespace drivermanager
 {
 
@@ -259,15 +255,6 @@ OSDBCDriverManager::~OSDBCDriverManager()
 {
 }
 
-// XComponent
-void SAL_CALL OSDBCDriverManager::dispose()
-{
-    OSDBCDriverManager_Base::dispose();
-    osl::MutexGuard aGuard(g_InstanceGuard);
-    g_Instance.clear();
-    g_Disposed = true;
-}
-
 void OSDBCDriverManager::bootstrapDrivers()
 {
     Reference< XContentEnumerationAccess > xEnumAccess( m_xContext->getServiceManager(), UNO_QUERY );
@@ -671,13 +658,8 @@ extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
 connectivity_OSDBCDriverManager_get_implementation(
     css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
 {
-    osl::MutexGuard aGuard(g_InstanceGuard);
-    if (g_Disposed)
-        return nullptr;
-    if (!g_Instance)
-        g_Instance.set(new drivermanager::OSDBCDriverManager(context));
-    g_Instance->acquire();
-    return static_cast<cppu::OWeakObject*>(g_Instance.get());
+    return cppu::acquire(
+        static_cast<cppu::OWeakObject*>(new drivermanager::OSDBCDriverManager(context)));
 }
 
 
diff --git a/connectivity/source/manager/mdrivermanager.hxx b/connectivity/source/manager/mdrivermanager.hxx
index 20fc0a72df7b..09ccd11e05c3 100644
--- a/connectivity/source/manager/mdrivermanager.hxx
+++ b/connectivity/source/manager/mdrivermanager.hxx
@@ -81,9 +81,6 @@ namespace drivermanager
             const css::uno::Reference< css::uno::XComponentContext >& _rxContext );
         virtual ~OSDBCDriverManager() override;
 
-    // XComponent
-        virtual void SAL_CALL dispose() override;
-
     // XDriverManager
         virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( const OUString& url ) override;
         virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnectionWithInfo( const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info ) override;
diff --git a/connectivity/source/manager/sdbc2.component b/connectivity/source/manager/sdbc2.component
index 8797ec80a27c..b9433256aabf 100644
--- a/connectivity/source/manager/sdbc2.component
+++ b/connectivity/source/manager/sdbc2.component
@@ -20,9 +20,7 @@
 <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
     xmlns="http://openoffice.org/2010/uno-components">
   <implementation name="com.sun.star.comp.sdbc.OSDBCDriverManager"
-    constructor="connectivity_OSDBCDriverManager_get_implementation">
-    <!-- fake singleton so the servicemanager shuts us down and we can clean up our global instance var -->
-    <singleton name="com.sun.star.comp.sdbc.theOSDBCDriverManager"/>
+    constructor="connectivity_OSDBCDriverManager_get_implementation" single-instance="true">
     <service name="com.sun.star.sdbc.DriverManager"/>
   </implementation>
 </component>


More information about the Libreoffice-commits mailing list