editeng/source/editeng/editeng.cxx |   34 +++-------------------------------
 1 file changed, 3 insertions(+), 31 deletions(-)

New commits:
commit 3fcdebc47275d739d8b68e66eca5cbafea8ffc7f
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sat Jul 13 15:06:42 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat Jul 13 18:48:25 2024 +0200

    use DeleteOnDeinit for EditEngine pool
    
    to avoid it accidentally coming to life during shutdown.
    
    Change-Id: I016a3396639c30350432b60c375c9777e551eb84
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170425
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/editeng/source/editeng/editeng.cxx 
b/editeng/source/editeng/editeng.cxx
index 1bc8ae77a564..172f6ad2c108 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -67,6 +67,7 @@
 #include <rtl/strbuf.hxx>
 #include <sal/log.hxx>
 #include <vcl/help.hxx>
+#include <vcl/lazydelete.hxx>
 #include <vcl/transfer.hxx>
 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
 #include <com/sun/star/frame/Desktop.hpp>
@@ -81,8 +82,6 @@ using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::linguistic2;
 
 
-static rtl::Reference<SfxItemPool> pGlobalPool;
-
 ImpEditEngine& EditEngine::getImpl() const
 {
     return *mpImpEditEngine;
@@ -1721,37 +1720,10 @@ rtl::Reference<SfxItemPool> EditEngine::CreatePool()
 }
 
 
-/** If we let the libc runtime clean us up, we trigger a crash */
-namespace
-{
-class TerminateListener : public ::cppu::WeakImplHelper< 
css::frame::XTerminateListener >
-{
-    void SAL_CALL queryTermination( const lang::EventObject& ) override
-    {}
-    void SAL_CALL notifyTermination( const lang::EventObject& ) override
-    {
-        pGlobalPool.clear();
-    }
-    virtual void SAL_CALL disposing( const ::css::lang::EventObject& ) override
-    {}
-};
-};
-
 SfxItemPool& EditEngine::GetGlobalItemPool()
 {
-    if ( !pGlobalPool )
-    {
-        pGlobalPool = CreatePool();
-#if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
-        // TerminateListener option not available, force it to leak
-        pGlobalPool->acquire();
-#else
-        uno::Reference< frame::XDesktop2 > xDesktop = 
frame::Desktop::create(comphelper::getProcessComponentContext());
-        uno::Reference< frame::XTerminateListener > xListener( new 
TerminateListener );
-        xDesktop->addTerminateListener( xListener );
-#endif
-    }
-    return *pGlobalPool;
+    static vcl::DeleteOnDeinit<rtl::Reference<SfxItemPool>> 
pGlobalPool(CreatePool());
+    return **pGlobalPool.get();
 }
 
 void EditEngine::SetFontInfoInItemSet( SfxItemSet& rSet, const vcl::Font& 
rFont )

Reply via email to