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 /svx | |
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 'svx')
-rw-r--r-- | svx/source/svdraw/svdobj.cxx | 25 |
1 files changed, 24 insertions, 1 deletions
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; |