summaryrefslogtreecommitdiff
path: root/chart2/source/view/main
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/view/main')
-rw-r--r--chart2/source/view/main/ChartItemPool.cxx25
1 files changed, 25 insertions, 0 deletions
diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx
index 8c2bf391953c..fef1b1f8f2d0 100644
--- a/chart2/source/view/main/ChartItemPool.cxx
+++ b/chart2/source/view/main/ChartItemPool.cxx
@@ -31,12 +31,15 @@
#include <editeng/sizeitem.hxx>
#include <svl/stritem.hxx>
#include <svl/ilstitem.hxx>
+#include <comphelper/processfactory.hxx>
#include <editeng/editids.hrc>
#include <svx/svxids.hrc>
#include <vector>
#include <com/sun/star/chart2/LegendPosition.hpp>
#include <com/sun/star/chart2/MovingAverageType.hpp>
+#include <com/sun/star/frame/XTerminateListener.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
namespace chart
{
@@ -216,6 +219,24 @@ MapUnit ChartItemPool::GetMetric(sal_uInt16 /* nWhich */) const
static rtl::Reference<SfxItemPool> g_Pool1, g_Pool2, g_Pool3;
+/** 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 css::lang::EventObject& ) override
+ {}
+ void SAL_CALL notifyTermination( const css::lang::EventObject& ) override
+ {
+ g_Pool1.clear();
+ g_Pool2.clear();
+ g_Pool3.clear();
+ }
+ virtual void SAL_CALL disposing( const ::css::lang::EventObject& ) override
+ {}
+};
+};
+
SfxItemPool& ChartItemPool::GetGlobalChartItemPool()
{
if (!g_Pool1)
@@ -232,6 +253,10 @@ SfxItemPool& ChartItemPool::GetGlobalChartItemPool()
g_Pool2->SetSecondaryPool(g_Pool3.get());
g_Pool1->FreezeIdRanges();
+
+ css::uno::Reference< css::frame::XDesktop2 > xDesktop = css::frame::Desktop::create(comphelper::getProcessComponentContext());
+ css::uno::Reference< css::frame::XTerminateListener > xListener( new TerminateListener );
+ xDesktop->addTerminateListener( xListener );
}
return *g_Pool1;
}