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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Mon Mar 22 10:58:29 UTC 2021


 framework/source/services/autorecovery.cxx |   26 +++++---------------------
 framework/util/fwk.component               |    3 ++-
 2 files changed, 7 insertions(+), 22 deletions(-)

New commits:
commit bc22a790b951da3364daa8f7c45dfc9547a8f717
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sun Mar 21 18:33:44 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Mar 22 11:57:46 2021 +0100

    use single-use attribute for AutoRecovery
    
    instead of rtl::Instance, which means it will get
    cleaned up when UNO shuts down
    
    Change-Id: I53c722e4126f5386b3cd43eee09ccfe4656ebd9e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112851
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx
index bdc46b1d73d4..085b627f5794 100644
--- a/framework/source/services/autorecovery.cxx
+++ b/framework/source/services/autorecovery.cxx
@@ -4219,25 +4219,6 @@ void AutoRecovery::st_impl_removeLockFile()
     }
 }
 
-struct Instance {
-    explicit Instance(
-        css::uno::Reference<css::uno::XComponentContext> const & context):
-        instance(
-            static_cast<cppu::OWeakObject *>(new AutoRecovery(context)))
-    {
-        // 2nd phase initialization needed
-        static_cast<AutoRecovery*>(static_cast<cppu::OWeakObject *>
-                (instance.get()))->initListeners();
-    }
-
-    css::uno::Reference<css::uno::XInterface> instance;
-};
-
-struct Singleton:
-    public rtl::StaticWithArg<
-        Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
-{};
-
 }
 
 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
@@ -4245,8 +4226,11 @@ com_sun_star_comp_framework_AutoRecovery_get_implementation(
     css::uno::XComponentContext *context,
     css::uno::Sequence<css::uno::Any> const &)
 {
-    return cppu::acquire(static_cast<cppu::OWeakObject *>(
-                Singleton::get(context).instance.get()));
+    rtl::Reference<AutoRecovery> xAutoRecovery = new AutoRecovery(context);
+    // 2nd phase initialization needed
+    xAutoRecovery->initListeners();
+
+    return cppu::acquire(xAutoRecovery.get());
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/util/fwk.component b/framework/util/fwk.component
index cc5fcfb13faa..aad750e76c72 100644
--- a/framework/util/fwk.component
+++ b/framework/util/fwk.component
@@ -28,7 +28,8 @@
     <service name="com.sun.star.ui.ToolBarFactory"/>
   </implementation>
   <implementation name="com.sun.star.comp.framework.AutoRecovery"
-      constructor="com_sun_star_comp_framework_AutoRecovery_get_implementation">
+      constructor="com_sun_star_comp_framework_AutoRecovery_get_implementation"
+      single-instance="true">
     <service name="com.sun.star.frame.AutoRecovery"/>
     <singleton name="com.sun.star.frame.theAutoRecovery"/>
   </implementation>


More information about the Libreoffice-commits mailing list