editeng/source/editeng/editeng.cxx | 24 ++++++++++++++++++++++++ svx/source/svdraw/svdobj.cxx | 25 ++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-)
New commits: commit 5295bc11e41166258fde5dc57b60f9677b5956e1 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri May 7 12:47:59 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon May 10 08:43:19 2021 +0200 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.gran...@collabora.co.uk> 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; } diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 9fc75da38f40..df38cf4a6d7a 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -26,6 +26,8 @@ #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/text/RelOrientation.hpp> +#include <com/sun/star/frame/XTerminateListener.hpp> +#include <com/sun/star/frame/Desktop.hpp> #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx> @@ -36,6 +38,7 @@ #include <basegfx/range/b2drange.hxx> #include <drawinglayer/processor2d/contourextractor2d.hxx> #include <drawinglayer/processor2d/linegeometryextractor2d.hxx> +#include <comphelper/processfactory.hxx> #include <editeng/editeng.hxx> #include <editeng/outlobj.hxx> #include <o3tl/deleter.hxx> @@ -546,8 +549,25 @@ void SdrObject::handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) } } + // global static ItemPool for not-yet-inserted items -static SdrItemPool* mpGlobalItemPool; +static rtl::Reference<SdrItemPool> mpGlobalItemPool; + +/** 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 + { + mpGlobalItemPool.clear(); + } + virtual void SAL_CALL disposing( const ::css::lang::EventObject& ) override + {} +}; +}; // init global static itempool SdrItemPool& SdrObject::GetGlobalDrawObjectItemPool() @@ -559,6 +579,9 @@ SdrItemPool& SdrObject::GetGlobalDrawObjectItemPool() mpGlobalItemPool->SetSecondaryPool(pGlobalOutlPool.get()); mpGlobalItemPool->SetDefaultMetric(SdrEngineDefaults::GetMapUnit()); mpGlobalItemPool->FreezeIdRanges(); + uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create(comphelper::getProcessComponentContext()); + uno::Reference< frame::XTerminateListener > xListener( new TerminateListener ); + xDesktop->addTerminateListener( xListener ); } return *mpGlobalItemPool; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits