diff options
author | Tor Lillqvist <tml@collabora.com> | 2019-06-11 08:12:14 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2019-06-11 08:26:48 +0300 |
commit | a11cdfd392dfcfe0117893e1fc4ca18c3bc69f66 (patch) | |
tree | 6cb2b6c44201c951c1ef68dc1e7609156354128f | |
parent | ff816ce335826937f92b6b30aca5ff75f56b3ec4 (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
-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 78254a834040..7df511f0016d 100644 --- a/extensions/source/ole/unoobjw.cxx +++ b/extensions/source/ole/unoobjw.cxx @@ -121,6 +121,7 @@ class TerminationVetoer : public WeakImplHelper<css::frame::XTerminateListener> public: int mnCount; +private: TerminationVetoer() : mnCount(0) { @@ -136,6 +137,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 { @@ -158,8 +168,6 @@ public: } }; -static TerminationVetoer aTerminationVetoer; - /* Does not throw any exceptions. Param pInfo can be NULL. */ @@ -178,7 +186,7 @@ InterfaceOleWrapper::InterfaceOleWrapper( Reference<XMultiServiceFactory> const UnoConversionUtilities<InterfaceOleWrapper>( xFactory, unoWrapperClass, comWrapperClass), m_defaultValueType( 0) { - aTerminationVetoer.mnCount++; + TerminationVetoer::get()->mnCount++; } InterfaceOleWrapper::~InterfaceOleWrapper() @@ -189,7 +197,7 @@ InterfaceOleWrapper::~InterfaceOleWrapper() if(it != UnoObjToWrapperMap.end()) UnoObjToWrapperMap.erase(it); - aTerminationVetoer.mnCount--; + TerminationVetoer::get()->mnCount--; } STDMETHODIMP InterfaceOleWrapper::QueryInterface(REFIID riid, LPVOID FAR * ppv) |