diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2024-07-13 15:06:42 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-07-13 18:48:25 +0200 |
commit | 3fcdebc47275d739d8b68e66eca5cbafea8ffc7f (patch) | |
tree | d76ee52d03cc4e9a81c1e0c70eaad5ce6d4955aa /editeng | |
parent | b5907f1d6e06bf6c28a06c87cfc4de7b7e96b454 (diff) |
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.grandin@collabora.co.uk>
Tested-by: Jenkins
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/editeng.cxx | 34 |
1 files changed, 3 insertions, 31 deletions
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 ) |