diff options
author | Tor Lillqvist <tml@collabora.com> | 2019-06-11 08:12:14 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2019-09-20 15:16:47 +0200 |
commit | b0f86853b51391b2c2a08b48efe90c619161a60f (patch) | |
tree | 0db86c2740fbba84f3c77f07ebb1917be060eb79 /extensions | |
parent | af222266e3522820c873bd9700c4bf542fd6cb04 (diff) |
It is not a good idea to allocate a UNO object statically
I should have known that. But sometimes you subconsciously just want
things to be easy for change. But no. This fixes a problem that showed
up in CppunitTest_services.
Change-Id: Iaefcbe4a07716f4d1b2c269627a99d43e3738af3
(cherry picked from commit a11cdfd392dfcfe0117893e1fc4ca18c3bc69f66)
Reviewed-on: https://gerrit.libreoffice.org/79246
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/source/ole/unoobjw.cxx | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/extensions/source/ole/unoobjw.cxx b/extensions/source/ole/unoobjw.cxx index 2ee61fd34ec2..9c70af4ad9c5 100644 --- a/extensions/source/ole/unoobjw.cxx +++ b/extensions/source/ole/unoobjw.cxx @@ -119,6 +119,7 @@ class TerminationVetoer : public WeakImplHelper<css::frame::XTerminateListener> public: int mnCount; +private: TerminationVetoer() : mnCount(0) { @@ -134,6 +135,15 @@ public: } } +public: + static Reference< TerminationVetoer > get() + { + static TerminationVetoer* pInstance = new TerminationVetoer; + static Reference< TerminationVetoer > aInstance( pInstance ); + + return aInstance; + } + // XTerminateListener void SAL_CALL queryTermination( const EventObject& ) override { @@ -156,8 +166,6 @@ public: } }; -static TerminationVetoer aTerminationVetoer; - /* Does not throw any exceptions. Param pInfo can be NULL. */ @@ -176,7 +184,7 @@ InterfaceOleWrapper::InterfaceOleWrapper( Reference<XMultiServiceFactory> const UnoConversionUtilities<InterfaceOleWrapper>( xFactory, unoWrapperClass, comWrapperClass), m_defaultValueType( 0) { - aTerminationVetoer.mnCount++; + TerminationVetoer::get()->mnCount++; } InterfaceOleWrapper::~InterfaceOleWrapper() @@ -187,7 +195,7 @@ InterfaceOleWrapper::~InterfaceOleWrapper() if(it != UnoObjToWrapperMap.end()) UnoObjToWrapperMap.erase(it); - aTerminationVetoer.mnCount--; + TerminationVetoer::get()->mnCount--; } STDMETHODIMP InterfaceOleWrapper::QueryInterface(REFIID riid, LPVOID FAR * ppv) |