diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-09-30 22:20:12 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-10-01 09:45:45 +0200 |
commit | 2f1bae744ad473df5de0a5e4882ca4e8b5f20618 (patch) | |
tree | 3fc53ae516b011c7d137f49f0620cfd69f0f8875 /dbaccess | |
parent | d9ba652064ee760448d0344d07347480cb195b6e (diff) |
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@redhat.com>
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/core/dataaccess/databasecontext.cxx | 21 | ||||
-rw-r--r-- | dbaccess/source/core/inc/databasecontext.hxx | 3 | ||||
-rw-r--r-- | dbaccess/util/dba.component | 4 |
3 files changed, 3 insertions, 25 deletions
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" |