diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-09-30 22:21:05 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-10-01 09:46:12 +0200 |
commit | 8e126adb49f47e4b94841c1dcb4628a8c64d597b (patch) | |
tree | fa48400cfbe8a4b518484f8e72ed654c0176b165 /scaddins | |
parent | 2f1bae744ad473df5de0a5e4882ca4e8b5f20618 (diff) |
Use the new single-instance="true" attribute in scaddins
Change-Id: I0d45a760276a4855c03c84f5a3a6fbbc98ddf840
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103737
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'scaddins')
-rw-r--r-- | scaddins/source/analysis/analysis.component | 4 | ||||
-rw-r--r-- | scaddins/source/analysis/analysis.cxx | 22 | ||||
-rw-r--r-- | scaddins/source/analysis/analysis.hxx | 3 |
3 files changed, 3 insertions, 26 deletions
diff --git a/scaddins/source/analysis/analysis.component b/scaddins/source/analysis/analysis.component index bda78b4e5ab9..86d26c24265f 100644 --- a/scaddins/source/analysis/analysis.component +++ b/scaddins/source/analysis/analysis.component @@ -20,10 +20,8 @@ <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" xmlns="http://openoffice.org/2010/uno-components"> <implementation name="com.sun.star.sheet.addin.AnalysisImpl" - constructor="scaddins_AnalysisAddIn_get_implementation"> + constructor="scaddins_AnalysisAddIn_get_implementation" single-instance="true"> <service name="com.sun.star.sheet.AddIn"/> <service name="com.sun.star.sheet.addin.Analysis"/> - <!-- fake singleton so that the servicemanager calls dispose() on the component and we can free the global var --> - <singleton name="com.sun.star.sheet.addin.theAnalysis"/> </implementation> </component> diff --git a/scaddins/source/analysis/analysis.cxx b/scaddins/source/analysis/analysis.cxx index 8b423b86331f..9db4d55fee6f 100644 --- a/scaddins/source/analysis/analysis.cxx +++ b/scaddins/source/analysis/analysis.cxx @@ -24,10 +24,10 @@ #include <comphelper/processfactory.hxx> #include <comphelper/random.hxx> #include <cppuhelper/supportsservice.hxx> +#include <cppuhelper/weak.hxx> #include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <o3tl/any.hxx> #include <rtl/math.hxx> -#include <rtl/ref.hxx> #include <sal/macros.h> #include <unotools/resmgr.hxx> #include <i18nlangtag/languagetag.hxx> @@ -43,10 +43,6 @@ using namespace ::com::sun::star; using namespace sca::analysis; using namespace std; -static osl::Mutex g_InstanceMutex; -static rtl::Reference<AnalysisAddIn> g_Instance; -static bool g_Disposed; - OUString AnalysisAddIn::GetFuncDescrStr(const char** pResId, sal_uInt16 nStrIndex) { return AnalysisResId(pResId[nStrIndex - 1]); @@ -72,14 +68,6 @@ AnalysisAddIn::~AnalysisAddIn() { } -void AnalysisAddIn::dispose() -{ - AnalysisAddIn_Base::dispose(); - osl::MutexGuard aGuard(g_InstanceMutex); - g_Instance.clear(); - g_Disposed = true; -} - sal_Int32 AnalysisAddIn::getDateMode( const uno::Reference< beans::XPropertySet >& xPropSet, const uno::Any& rAny ) @@ -1069,13 +1057,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* scaddins_AnalysisAddIn_get_implementation( css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) { - osl::MutexGuard aGuard(g_InstanceMutex); - if (g_Disposed) - return nullptr; - if (!g_Instance) - g_Instance.set(new AnalysisAddIn(context)); - g_Instance->acquire(); - return static_cast<cppu::OWeakObject*>(g_Instance.get()); + return cppu::acquire(static_cast<cppu::OWeakObject*>(new AnalysisAddIn(context))); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/scaddins/source/analysis/analysis.hxx b/scaddins/source/analysis/analysis.hxx index dbfe11a9c2c0..f595134cfd33 100644 --- a/scaddins/source/analysis/analysis.hxx +++ b/scaddins/source/analysis/analysis.hxx @@ -78,9 +78,6 @@ public: virtual ~AnalysisAddIn() override; - // XComponent - virtual void SAL_CALL dispose() override; - /// @throws css::uno::RuntimeException /// @throws css::lang::IllegalArgumentException double FactDouble( sal_Int32 nNum ); |