[Libreoffice-commits] core.git: dbaccess/source dbaccess/util

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


 dbaccess/source/core/dataaccess/databasecontext.cxx |   21 +-------------------
 dbaccess/source/core/inc/databasecontext.hxx        |    3 --
 dbaccess/util/dba.component                         |    4 ---
 3 files changed, 3 insertions(+), 25 deletions(-)

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

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

diff --git a/dbaccess/source/core/dataaccess/databasecontext.cxx b/dbaccess/source/core/dataaccess/databasecontext.cxx
index 01d83bafa7ee..b57cd9be52db 100644
--- a/dbaccess/source/core/dataaccess/databasecontext.cxx
+++ b/dbaccess/source/core/dataaccess/databasecontext.cxx
@@ -54,6 +54,7 @@
 #include <cppuhelper/supportsservice.hxx>
 #include <cppuhelper/typeprovider.hxx>
 #include <cppuhelper/exc_hlp.hxx>
+#include <cppuhelper/weak.hxx>
 #include <rtl/uri.hxx>
 #include <sal/log.hxx>
 #include <svl/filenotation.hxx>
@@ -85,10 +86,6 @@ using ::com::sun::star::ucb::InteractiveIOException;
 using ::com::sun::star::ucb::IOErrorCode_NOT_EXISTING;
 using ::com::sun::star::ucb::IOErrorCode_NOT_EXISTING_PATH;
 
-static osl::Mutex g_InstanceGuard;
-static rtl::Reference<dbaccess::ODatabaseContext> g_Instance;
-static bool g_Disposed = false;
-
 namespace dbaccess
 {
 
@@ -267,14 +264,6 @@ void ODatabaseContext::disposing()
     }
 }
 
-void ODatabaseContext::dispose()
-{
-    DatabaseAccessContext_Base::dispose();
-    osl::MutexGuard aGuard(g_InstanceGuard);
-    g_Instance.clear();
-    g_Disposed = true;
-}
-
 // XNamingService
 Reference< XInterface >  ODatabaseContext::getRegisteredObject(const OUString& _rName)
 {
@@ -762,13 +751,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
 com_sun_star_comp_dba_ODatabaseContext_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 dbaccess::ODatabaseContext(context));
-    g_Instance->acquire();
-    return static_cast<cppu::OWeakObject*>(g_Instance.get());
+    return cppu::acquire(static_cast<cppu::OWeakObject*>(new dbaccess::ODatabaseContext(context)));
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/core/inc/databasecontext.hxx b/dbaccess/source/core/inc/databasecontext.hxx
index 8cfa0eb2b6df..4f561ebd2401 100644
--- a/dbaccess/source/core/inc/databasecontext.hxx
+++ b/dbaccess/source/core/inc/databasecontext.hxx
@@ -115,9 +115,6 @@ public:
     // OComponentHelper
     virtual void SAL_CALL disposing() override;
 
-    // XComponent
-    virtual void SAL_CALL dispose() override;
-
     // XSingleServiceFactory
     virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance(  ) override;
     virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( const css::uno::Sequence< css::uno::Any >& _rArguments ) override;
diff --git a/dbaccess/util/dba.component b/dbaccess/util/dba.component
index 83795ff82f77..7fcf892bb489 100644
--- a/dbaccess/util/dba.component
+++ b/dbaccess/util/dba.component
@@ -37,9 +37,7 @@
     <service name="com.sun.star.sdb.TableDefinition"/>
   </implementation>
   <implementation name="com.sun.star.comp.dba.ODatabaseContext"
-    constructor="com_sun_star_comp_dba_ODatabaseContext_get_implementation">
-     <!-- fake singleton so the servicemanager calls dispose() on us so we can clean up the global -->
-    <singleton name="com.sun.star.comp.dba.theODatabaseContext"/>
+    constructor="com_sun_star_comp_dba_ODatabaseContext_get_implementation" single-instance="true">
     <service name="com.sun.star.sdb.DatabaseContext"/>
   </implementation>
   <implementation name="com.sun.star.comp.dba.ODatabaseDocument"


More information about the Libreoffice-commits mailing list