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

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


 scaddins/source/analysis/analysis.component |    4 +---
 scaddins/source/analysis/analysis.cxx       |   22 ++--------------------
 scaddins/source/analysis/analysis.hxx       |    3 ---
 3 files changed, 3 insertions(+), 26 deletions(-)

New commits:
commit 8e126adb49f47e4b94841c1dcb4628a8c64d597b
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Wed Sep 30 22:21:05 2020 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Thu Oct 1 09:46:12 2020 +0200

    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 at redhat.com>

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 );


More information about the Libreoffice-commits mailing list