diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-07 12:47:59 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-10 08:43:19 +0200 |
commit | 5295bc11e41166258fde5dc57b60f9677b5956e1 (patch) | |
tree | 2c297c14f742a4d7399edb715684afc85142d466 /editeng/source | |
parent | 47a9ee003ceb18ba9f26d2e0035d3faf1779ab05 (diff) |
do not leak SdrObject global pool on shutdown
Change-Id: Id2948f044edc7a4c9497ece5fe7d497e826bc04b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115237
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'editeng/source')
-rw-r--r-- | editeng/source/editeng/editeng.cxx | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 208e502f6215..992d3f3c515f 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -21,6 +21,7 @@ #include <utility> #include <comphelper/lok.hxx> +#include <comphelper/processfactory.hxx> #include <config_global.h> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> @@ -67,6 +68,7 @@ #include <vcl/help.hxx> #include <vcl/transfer.hxx> #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp> +#include <com/sun/star/frame/Desktop.hpp> #if OSL_DEBUG_LEVEL > 1 #include <editeng/frmdiritem.hxx> @@ -2594,10 +2596,32 @@ rtl::Reference<SfxItemPool> EditEngine::CreatePool() return new EditEngineItemPool(); } + +/** 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(); + uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create(comphelper::getProcessComponentContext()); + uno::Reference< frame::XTerminateListener > xListener( new TerminateListener ); + xDesktop->addTerminateListener( xListener ); + } return *pGlobalPool; } |