diff options
Diffstat (limited to 'framework/source/services/desktop.cxx')
-rw-r--r-- | framework/source/services/desktop.cxx | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx index 3e5f3a0242bc..18eecb3a3ead 100644 --- a/framework/source/services/desktop.cxx +++ b/framework/source/services/desktop.cxx @@ -335,6 +335,14 @@ sal_Bool SAL_CALL Desktop::terminate() if ( xPipeTerminator.is() ) xPipeTerminator->notifyTermination( aEvent ); + // we need a copy here as the notifyTermination call might cause a removeTerminateListener call + std::vector< css::uno::Reference<css::frame::XTerminateListener> > xComponentDllListeners = m_xComponentDllListeners; + for (auto& xListener : xComponentDllListeners) + { + xListener->notifyTermination(aEvent); + } + m_xComponentDllListeners.clear(); + // Must be really the last listener to be called. // Because it shutdown the whole process asynchronous ! if ( xSfxTerminator.is() ) @@ -407,6 +415,11 @@ void SAL_CALL Desktop::addTerminateListener( const css::uno::Reference< css::fra m_xSWThreadManager = xListener; return; } + else if ( sImplementationName == "com.sun.star.comp.ComponentDLLListener" ) + { + m_xComponentDllListeners.push_back(xListener); + return; + } } // No lock required ... container is threadsafe by itself. @@ -448,6 +461,13 @@ void SAL_CALL Desktop::removeTerminateListener( const css::uno::Reference< css:: m_xSWThreadManager.clear(); return; } + else if (sImplementationName == "com.sun.star.comp.ComponentDLLListener") + { + m_xComponentDllListeners.erase( + std::remove(m_xComponentDllListeners.begin(), m_xComponentDllListeners.end(), xListener), + m_xComponentDllListeners.end()); + return; + } } // No lock required ... container is threadsafe by itself. @@ -1076,6 +1096,15 @@ void SAL_CALL Desktop::disposing() m_xPipeTerminator.clear(); m_xQuickLauncher.clear(); m_xSWThreadManager.clear(); + + // we need a copy because the notifyTermination might call the removeEventListener method + std::vector< css::uno::Reference<css::frame::XTerminateListener> > xComponentDllListeners = m_xComponentDllListeners; + for (auto& xListener: xComponentDllListeners) + { + xListener->notifyTermination(aEvent); + } + xComponentDllListeners.clear(); + m_xComponentDllListeners.clear(); m_xSfxTerminator.clear(); m_xCommandOptions.reset(); |